Class: Devbootcamp::Rails::AuthenticationController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Devbootcamp::Rails::AuthenticationController
- Defined in:
- lib/devbootcamp/rails/authentication_controller.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
28 29 30 31 |
# File 'lib/devbootcamp/rails/authentication_controller.rb', line 28 def destroy unauthenticate! redirect_to end |
#new ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/devbootcamp/rails/authentication_controller.rb', line 5 def new destination_url = params[:r] || root_url if authenticated? redirect_to destination_url else session[:post_authorization_destination_url] = destination_url redirect_to end end |
#oauth_callback ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/devbootcamp/rails/authentication_controller.rb', line 15 def oauth_callback oauth_code = params[:code] if Devbootcamp::OAuth.(oauth_code) self.current_user = Devbootcamp::User.me session[:oauth_token] = Devbootcamp::OAuth.token_as_hash flash[:notice] = "Welcome back #{current_user.name}" else flash[:error] = 'Authorization Failed' end redirect_to session[:post_authorization_destination_url] || root_url end |