Class: Users::OmniauthCallbacksController
- Inherits:
-
Devise::OmniauthCallbacksController
- Object
- Devise::OmniauthCallbacksController
- Users::OmniauthCallbacksController
- Defined in:
- app/controllers/users/omniauth_callbacks_controller.rb
Overview
app/controllers/users/omniauth_callbacks_controller.rb
Instance Method Summary collapse
- #auth ⇒ Object
- #callback(name, from_params, provider) ⇒ Object
- #from_params ⇒ Object
- #google ⇒ Object
- #microsoft ⇒ Object
Instance Method Details
#auth ⇒ Object
37 38 39 |
# File 'app/controllers/users/omniauth_callbacks_controller.rb', line 37 def auth @auth ||= request.env['omniauth.auth'] end |
#callback(name, from_params, provider) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/users/omniauth_callbacks_controller.rb', line 11 def callback name, from_params, provider Rails.logger.info "#{name} callback received with params: #{from_params.inspect}" user = ThecoreAuthCommons.check_user from_params[:email], from_params[:name], from_params[:surname], provider if user.present? sign_out_all_scopes flash[:notice] = t 'devise.omniauth_callbacks.success', kind: name sign_in_and_redirect user, event: :authentication else flash[:alert] = t 'devise.omniauth_callbacks.failure', kind: name, reason: "#{from_params[:email]} is not authorized." redirect_to new_user_session_path end end |
#from_params ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/users/omniauth_callbacks_controller.rb', line 26 def from_params Rails.logger.info "Omniauth params: #{auth.info.inspect}" @from_params ||= { uid: auth.uid, email: auth.info.email, # in the params from Microsoft or Google there must be laso the name and surname, maybe with different key, assign them to the name and surname keys in this object name: auth.info.given_name.presence || auth.info.first_name.presence || auth.info.name, surname: auth.info.family_name.presence || auth.info.last_name.presence || auth.info.surname } end |
#google ⇒ Object
3 4 5 |
# File 'app/controllers/users/omniauth_callbacks_controller.rb', line 3 def google callback 'Google', from_params, 'google' end |
#microsoft ⇒ Object
7 8 9 |
# File 'app/controllers/users/omniauth_callbacks_controller.rb', line 7 def microsoft callback 'Microsoft Entra ID', from_params, 'entra_id' end |