Module: Accountable

Extended by:
ActiveSupport::Concern
Includes:
SentryLogging
Included in:
Login::AfterLoginActions
Defined in:
app/controllers/concerns/accountable.rb

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Instance Method Details

#account_login_statsObject (private)



19
20
21
22
23
24
25
26
27
# File 'app/controllers/concerns/accountable.rb', line 19

def 
  @account_login_stats ||=
    if @current_user..present?
      AccountLoginStat.find_or_initialize_by(account_id: @current_user.)
    else
      
      nil
    end
end

#log_error(error, tag_hash) ⇒ Object (private)



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_messageObject (private)



47
48
49
50
51
52
53
54
55
# File 'app/controllers/concerns/accountable.rb', line 47

def 
  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 ()
  return unless .present? && .in?(SAML::User::LOGIN_TYPES)

   =  == SAML::User::MHV_ORIGINAL_CSID ? SAML::User::MHV_MAPPED_CSID : 

  .update!("#{}_at" => Time.zone.now, current_verification: verification_level)
rescue => e
  log_error(e, account_login_stats: 'update_failed')
end

#verification_levelObject (private)



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