11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/graphql_devise/mutations/login.rb', line 11
def resolve(email:, password:)
resource = find_resource(
:email,
get_case_insensitive_field(:email, email)
)
if resource && active_for_authentication?(resource)
if invalid_for_authentication?(resource, password)
raise_user_error(I18n.t('graphql_devise.sessions.bad_credentials'))
end
= (resource)
controller.sign_in(:user, resource, store: false, bypass: false)
yield resource if block_given?
context[:current_resource] = resource if context[:current_resource].nil?
{ authenticatable: resource, credentials: }
elsif resource && !active_for_authentication?(resource)
if locked?(resource)
raise_user_error(I18n.t('graphql_devise.mailer.unlock_instructions.account_lock_msg'))
else
raise_user_error(I18n.t('graphql_devise.sessions.not_confirmed', email: resource.email))
end
else
raise_user_error(I18n.t('graphql_devise.sessions.bad_credentials'))
end
end
|