Module: Accountable
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Method Details
#account_login_stats ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/concerns/accountable.rb', line 19
def account_login_stats
@account_login_stats ||=
if @current_user.account_id.present?
AccountLoginStat.find_or_initialize_by(account_id: @current_user.account_id)
else
no_account_log_message
nil
end
end
|
#log_error(error, tag_hash) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/concerns/accountable.rb', line 35
def log_error(error, tag_hash)
log_exception_to_sentry(
error,
{
error: error.inspect,
idme_uuid: @current_user.idme_uuid,
logingov_uuid: @current_user.logingov_uuid
},
tag_hash
)
end
|
#no_account_log_message ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/concerns/accountable.rb', line 47
def no_account_log_message
log_message_to_sentry(
'No account found for user',
:warn,
{ idme_uuid: @current_user.idme_uuid,
logingov_uuid: @current_user.logingov_uuid },
account_login_stats: 'no_account_found'
)
end
|
#update_account_login_stats(login_type) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/concerns/accountable.rb', line 7
def update_account_login_stats(login_type)
return unless account_login_stats.present? && login_type.in?(SAML::User::LOGIN_TYPES)
login_type = login_type == SAML::User::MHV_ORIGINAL_CSID ? SAML::User::MHV_MAPPED_CSID : login_type
account_login_stats.update!("#{login_type}_at" => Time.zone.now, current_verification: verification_level)
rescue => e
log_error(e, account_login_stats: 'update_failed')
end
|
#verification_level ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/concerns/accountable.rb', line 29
def verification_level
AccountLoginStat::VERIFICATION_LEVELS.detect do |str|
@current_user.identity.authn_context&.gsub('/', '')&.scan(/#{str}/)&.present?
end
end
|