Class: CloudhdrAuth::UserSessionsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- CloudhdrAuth::UserSessionsController
- Defined in:
- app/controllers/cloudhdr_auth/user_sessions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
omniauth callback method.
-
#destroy ⇒ Object
logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too !.
-
#failure ⇒ Object
Omniauth failure callback.
Methods inherited from BaseController
#auth_redirect, #check_cookie, #current_user, #login_required, #not_authorized, #signed_in?
Instance Method Details
#create ⇒ Object
omniauth callback method
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/cloudhdr_auth/user_sessions_controller.rb', line 7 def create omniauth = request.env['omniauth.auth'] logger.debug "+++ #{omniauth}" user = User.find_by_id(omniauth['uid']) if not user # New user registration user = User.new # avoid trouble with attr_accessible user.id = omniauth['uid'] end user.current_sign_in_at = omniauth['extra']['current_sign_in_at'] if user.respond_to?(:current_sign_in_at) user.name = omniauth['extra']['name'] if user.respond_to?(:name) #user.first_name = omniauth['extra']['first_name'] #user.last_name = omniauth['extra']['last_name'] user.save! #p omniauth # Currently storing all the info session[:user_id] = omniauth flash[:notice] = "Successfully logged in" redirect_to request.env['omniauth.origin'] || root_path end |
#destroy ⇒ Object
logout - Clear our rack session BUT essentially redirect to the provider to clean up the Devise session from there too !
40 41 42 43 44 45 |
# File 'app/controllers/cloudhdr_auth/user_sessions_controller.rb', line 40 def destroy session[:user_id] = nil flash[:notice] = 'You have successfully signed out!' redirect_to "#{CUSTOM_PROVIDER_URL}/users/sign_out" end |
#failure ⇒ Object
Omniauth failure callback
34 35 36 |
# File 'app/controllers/cloudhdr_auth/user_sessions_controller.rb', line 34 def failure flash[:notice] = params[:message] end |