Created
October 20, 2010 03:55
-
-
Save esparkman/635738 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def create | |
| omniauth = request.env["omniauth.auth"] | |
| authentication = Authentication.find_by_provider(omniauth['provider'], omniauth['uid']) | |
| if authentication | |
| flash[:notice] = "Signed in successfully." | |
| sign_in_and_redirect(:user, authentication.user) | |
| elsif current_user | |
| current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid']) | |
| flash[:notice] = "Authentication successful." | |
| redirect_to authentications_url | |
| else | |
| user = User.new | |
| user.apply_omniauth(omniauth) | |
| if user.save | |
| flash[:notice] = "Signed in successfully." | |
| sign_in_and_redirect(:user, user) | |
| else | |
| session[:omniauth] = omniauth.except('extra') | |
| redirect_to new_user_registration_url | |
| end | |
| end | |
| end |
This file contains hidden or 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
| NoMethodError in AuthenticationsController#create | |
| undefined method `id' for :user:Symbol | |
| Rails.root: /Users/esparkman/Programming/Rails/clientmanager | |
| Application Trace | Framework Trace | Full Trace | |
| app/controllers/authentications_controller.rb:11:in `create' | |
| Request | |
| Parameters: | |
| {"provider"=>"google_apps"} | |
| Show session dump | |
| Show env dump | |
| Response | |
| Headers: | |
| None |
This file contains hidden or 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
| TypeError in AuthenticationsController#create | |
| exception class/object expected | |
| Rails.root: /Users/esparkman/Programming/Rails/clientmanager | |
| Application Trace | Framework Trace | Full Trace | |
| app/controllers/authentications_controller.rb:9:in `raise' | |
| app/controllers/authentications_controller.rb:9:in `create' | |
| Request | |
| Parameters: | |
| {"provider"=>"google_apps"} | |
| Show session dump | |
| Show env dump | |
| Response | |
| Headers: | |
| None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment