Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Adds Facebook sign-in / registration
Browse files Browse the repository at this point in the history
Fixes #222 (as far as Facebook at least)

This was fairly straightforward with a few hiccups. I implemented Facebook because that is the one in the tutorial. I attempted to move some other stuff around (`RegistrationsController`) to match the submodule approach.

Things it does not support

- [ ] Newsletter preference (isn't passed through)
- [ ] Group invitation code (personalized group code)
- [ ] Group signup code (the group "public" signup code)
- [ ] Entity registration (skip search for team in group creation)
  • Loading branch information
stephenyeargin committed Aug 25, 2015
1 parent 5ceae86 commit 99f4d9f
Show file tree
Hide file tree
Showing 18 changed files with 369 additions and 235 deletions.
3 changes: 3 additions & 0 deletions .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export TWILIO_ACCOUNT_SID=some_sid
export TWILIO_AUTH_TOKEN=some_token
export TWILIO_OUTBOUND_NUMBER=the_number

export OMNIAUTH_FACEBOOK_APP_ID=the_app_id
export OMNIAUTH_FACEBOOK_APP_SECRET=the_app_secret

export SLACK_WEBHOOK_URL=webook_url

# These values are production only
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ gem 'newrelic_rpm', group: :production
# Select2
gem 'select2-rails'

# OmniAuth
gem 'omniauth-facebook'

# ActiveAdmin
gem 'activeadmin', github: 'activeadmin'

Expand Down
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ GEM
eventmachine (1.0.8)
excon (0.45.4)
execjs (2.5.2)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.10)
font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0)
Expand Down Expand Up @@ -170,6 +172,7 @@ GEM
has_scope (0.6.0)
actionpack (>= 3.2, < 5)
activesupport (>= 3.2, < 5)
hashie (3.4.2)
hike (1.2.3)
http-cookie (1.0.2)
domain_name (~> 0.5)
Expand Down Expand Up @@ -217,6 +220,7 @@ GEM
railties (>= 3.1)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nenv (0.2.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
Expand All @@ -228,6 +232,20 @@ GEM
notiffany (0.0.7)
nenv (~> 0.1)
shellany (~> 0.0)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (2.0.1)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
orm_adapter (0.5.0)
paperclip (4.2.4)
activemodel (>= 3.2.0)
Expand Down Expand Up @@ -404,6 +422,7 @@ DEPENDENCIES
mailchimp-api (~> 2.0.5)
momentjs-rails
newrelic_rpm
omniauth-facebook
paperclip (~> 4.2.1)
pg
pry-nav
Expand Down
25 changes: 19 additions & 6 deletions app/assets/stylesheets/login.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ body.login {

}

div.logo {
.facebook_signin {
margin-bottom: 1.5em;
i {
margin-right: 1em;
}
a, a:hover {
color: #fff;
text-decoration: none;
}
}

.logo {
background-image: image-url('seatshare-inverted.svg');
background-repeat: no-repeat;
background-position: center;
Expand All @@ -67,11 +78,13 @@ body.login {
margin-left: auto;
margin-right: auto;
overflow-y: hidden;
}

div.logo a {
display: block;
width: 290px;
padding-top: 100px;
a {
display: block;
width: 290px;
padding-top: 100px;
}

}

}
9 changes: 9 additions & 0 deletions app/assets/stylesheets/registrations.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.facebook_register {
text-align:center;
margin: 3em 0;
a {
i {
margin-right: 2em;
}
}
}
162 changes: 0 additions & 162 deletions app/controllers/registrations_controller.rb

This file was deleted.

20 changes: 20 additions & 0 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
##
# Users :: OminiAuth Callbacks Controller
module Users
##
# Users :: OminiAuth Callbacks Controller
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.from_omniauth(request.env['omniauth.auth'])
if @user.persisted?
sign_in_and_redirect @user
set_flash_message(
:notice, :success, kind: 'Facebook'
) if is_navigational_format?
else
session['devise.facebook_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
end
end
end
Loading

0 comments on commit 99f4d9f

Please sign in to comment.