Class: OmniauthController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- OmniauthController
- Defined in:
- lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb
Instance Method Summary collapse
- #failure ⇒ Object
-
#login ⇒ Object
logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too !.
- #logout ⇒ Object
- #success ⇒ Object
Instance Method Details
#failure ⇒ Object
10 11 12 13 |
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 10 def failure flash[:alert] = params[:message] #remember to add a template to render out or redirect to somewhere end |
#login ⇒ Object
logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too !
16 17 18 19 |
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 16 def login params[:provider] = "infinum" if !params[:provider] redirect_to "/auth/#{params[:provider]}?redirect_to=#{root_url}" end |
#logout ⇒ Object
21 22 23 24 |
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 21 def logout session[:user_id] = nil redirect_to "#{ENV['omniauth_infinum_url']}/users/sign_out?redirect_to=#{root_url}", notice: 'You have successfully signed out!' end |
#success ⇒ Object
4 5 6 7 8 |
# File 'lib/generators/infinum/omniauth/templates/rails/app/controllers/omniauth_controller.rb', line 4 def success session[:user_id] = env['omniauth.auth'] user = USER_MODEL.new_from_omniauth(session[:user_id]) redirect_to request.env['omniauth.origin'] || root_path, notice: "Successfully logged in" end |