Class: SpreeCmCommissioner::UserIdentityChecker

Inherits:
BaseInteractor show all
Defined in:
app/interactors/spree_cm_commissioner/user_identity_checker.rb

Instance Method Summary collapse

Instance Method Details

#callObject

expects:

context.identity_type
context.sub
context.tenant_id (optional)


9
10
11
12
13
14
15
16
# File 'app/interactors/spree_cm_commissioner/user_identity_checker.rb', line 9

def call
  load_user

  return unless context.user.nil?

  error_message = I18n.t('user_identity_provider.not_found', identity_type: identity_type)
  context.fail!(message: error_message)
end

#load_userObject



18
19
20
21
22
23
24
25
26
# File 'app/interactors/spree_cm_commissioner/user_identity_checker.rb', line 18

def load_user
  return if sub.blank? || identity_type.blank?

  user_identity_providers = UserIdentityProvider.joins(:user)
                                                .where(identity_type: identity_type, sub: sub)
                                                .where(spree_users: { tenant_id: tenant_id })

  context.user = user_identity_providers.first&.user
end