Class: V2Users::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
app/controllers/v2_users/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#after_omniauth_failure_path_for(_scope) ⇒ Object



38
39
40
# File 'app/controllers/v2_users/omniauth_callbacks_controller.rb', line 38

def after_omniauth_failure_path_for(_scope)
  new_user_registration_url
end

#facebookObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/v2_users/omniauth_callbacks_controller.rb', line 7

def facebook
  operation = AccountCpt::Registration::RegularUser::WithFacebook.call(
    request.env['omniauth.auth'],
    fb_options
  )

  if operation.success?
    # `event: :authentication` will throw if @user is not activated
     operation[OpCons::OPERATION_RESULT], event: :authentication
    set_flash_message(:notice, :success, kind: 'Facebook') if is_navigational_format?
  else
    session['devise.facebook_data'] = request.env['omniauth.auth']
    alert = operation[OpCons::ERRORS]&.full_messages&.to_sentence&.presence || 'Something went wrong'
    redirect_to new_user_registration_url, alert: alert
  end
end

#failureObject



42
43
44
# File 'app/controllers/v2_users/omniauth_callbacks_controller.rb', line 42

def failure
  redirect_to new_user_registration_url
end

#google_oauth2Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/v2_users/omniauth_callbacks_controller.rb', line 24

def google_oauth2
  operation = AccountCpt::Session::StaffUser::WithGoogle.call(
    request.env['omniauth.auth']
  )

  if operation.success?
     operation[OpCons::OPERATION_RESULT]
    redirect_to admin_root_path
  else
    alert = operation[OpCons::ERRORS].full_messages.to_sentence
    redirect_to new_admin_session_path, alert: alert
  end
end