Class: RailsBase::Authentication::VerifyForgotPassword
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- RailsBase::Authentication::VerifyForgotPassword
show all
- Defined in:
- app/services/rails_base/authentication/verify_forgot_password.rb
Instance Method Summary
collapse
Methods inherited from ServiceBase
inherited, #internal_validate, #service_base_logging
#aletered_message, #class_name, #log, #log_prefix, #logger, #service_id
Instance Method Details
#call ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/services/rails_base/authentication/verify_forgot_password.rb', line 5
def call
data_point = short_lived_data
validate_datum?(data_point)
log(level: :info, msg: "Validated user 2fa email #{data_point[:user].full_name}")
context.user = data_point[:user]
mfa_decision = RailsBase::Mfa::Decision.(force_mfa: true, user: data_point[:user])
if context.mfa_flow = mfa_decision.mfa_require
log(level: :info, msg: "User has #{mfa_decision.mfa_options} mfa options enabled. MFA is required to reset password")
else
log(level: :info, msg: "User has no MFA options enabled. MFA is NOT required to reset password")
end
end
|
#short_lived_data ⇒ Object
35
36
37
|
# File 'app/services/rails_base/authentication/verify_forgot_password.rb', line 35
def short_lived_data
ShortLivedData.find_datum(data: data, reason: Constants::VFP_REASON)
end
|
#validate! ⇒ Object
39
40
41
|
# File 'app/services/rails_base/authentication/verify_forgot_password.rb', line 39
def validate!
raise "Expected data to be a String. Received #{data.class}" unless data.is_a? String
end
|
#validate_datum?(datum) ⇒ Boolean
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/services/rails_base/authentication/verify_forgot_password.rb', line 21
def validate_datum?(datum)
return true if datum[:valid]
if datum[:found]
msg = "Errors with email validation: #{datum[:invalid_reason].join(", ")}. Please go through forget password flow again."
log(level: :warn, msg: msg)
context.fail!(message: msg, redirect_url: Constants::URL_HELPER.new_user_password_path, level: :warn)
end
log(level: :warn, msg: "Could not find MFA code. Incorrect MFA code. User is doing something fishy.")
context.fail!(message: Constants::MV_FISHY, redirect_url: Constants::URL_HELPER.unauthenticated_root_path, level: :warn)
end
|