Class: AccountCpt::Session::StaffUser::WithGoogle
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- AccountCpt::Session::StaffUser::WithGoogle
- Includes:
- ErrorOperationHelper
- Defined in:
- app/concepts/account_cpt/session/staff_user/with_google.rb
Overview
return registered user
Instance Method Summary collapse
- #normalize_params!(options) ⇒ Object
- #register_with_google!(options) ⇒ Object
- #set_error_messages!(options, options2) ⇒ Object
Methods included from ErrorOperationHelper
Instance Method Details
#normalize_params!(options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/concepts/account_cpt/session/staff_user/with_google.rb', line 13 def normalize_params!() original_params = ['params'].dup ['original_params'] = original_params ['params'] = { 'provider' => 'google_oauth2', 'fb_uid' => original_params['uid'], 'email' => original_params['info']['email'], 'username' => original_params['info']['name'], 'fb_access_token' => original_params['credentials']['token'] } unless ['params']['email'].include?('@hungryhub.com') errors.add(:base, 'Your account is not valid') return false end true end |
#register_with_google!(options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/concepts/account_cpt/session/staff_user/with_google.rb', line 30 def register_with_google!(, **) user = User.find_or_initialize_by email: ['params']['email'] if user.new_record? user.assign_attributes ['params'] user.password = Devise.friendly_token unless user.valid? merge_errors { user.errors } return false end else user.update_attributes provider: :google_oauth2 end [OpCons::OPERATION_RESULT] = user true end |
#set_error_messages!(options, options2) ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/concepts/account_cpt/session/staff_user/with_google.rb', line 46 def (, , **) APMErrorHandler.report('Google sign in error', options: , options2: ) if errors..length.zero? errors.add(:base, 'Something went wrong') end true end |