-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrating omniauth-coursera into our devise setup
- Loading branch information
Showing
6 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
def google_oauth2 | ||
# You need to implement the method below in your model (e.g. app/models/user.rb) | ||
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user) | ||
|
||
if @user.persisted? | ||
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google" | ||
sign_in_and_redirect @user, :event => :authentication | ||
else | ||
session["devise.google_data"] = request.env["omniauth.auth"] | ||
redirect_to new_user_registration_url | ||
end | ||
end | ||
def coursera | ||
# FIXME: this needs to be worked out | ||
|
||
# You need to implement the method below in your model (e.g. app/models/user.rb) | ||
@user = User.find_for_coursera(request.env["omniauth.auth"], current_user) | ||
|
||
if @user.persisted? | ||
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Coursera" | ||
sign_in_and_redirect @user, :event => :authentication | ||
else | ||
session["devise.coursera_data"] = request.env["omniauth.auth"] | ||
redirect_to new_user_registration_url | ||
end | ||
end | ||
|
||
# This is necessary since Rails 3.0.4 | ||
# See https://github.com/intridea/omniauth/issues/185 | ||
# and http://www.arailsdemo.com/posts/44 | ||
protected | ||
def handle_unverified_request | ||
true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :developer unless Rails.env.production? | ||
# provider :developer unless Rails.env.production? | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters