Class: SignIn::CredentialLevel

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/sign_in/credential_level.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(requested_acr:, credential_type:, current_ial:, max_ial:, auto_uplevel: false) ⇒ CredentialLevel

Returns a new instance of CredentialLevel.



21
22
23
24
25
26
27
28
29
# File 'app/models/sign_in/credential_level.rb', line 21

def initialize(requested_acr:, credential_type:, current_ial:, max_ial:, auto_uplevel: false)
  @requested_acr = requested_acr
  @credential_type = credential_type
  @current_ial = current_ial
  @max_ial = max_ial
  @auto_uplevel = auto_uplevel

  validate!
end

Instance Attribute Details

#auto_uplevelObject (readonly)

Returns the value of attribute auto_uplevel.



7
8
9
# File 'app/models/sign_in/credential_level.rb', line 7

def auto_uplevel
  @auto_uplevel
end

#credential_typeObject (readonly)

Returns the value of attribute credential_type.



7
8
9
# File 'app/models/sign_in/credential_level.rb', line 7

def credential_type
  @credential_type
end

#current_ialObject (readonly)

Returns the value of attribute current_ial.



7
8
9
# File 'app/models/sign_in/credential_level.rb', line 7

def current_ial
  @current_ial
end

#max_ialObject (readonly)

Returns the value of attribute max_ial.



7
8
9
# File 'app/models/sign_in/credential_level.rb', line 7

def max_ial
  @max_ial
end

#requested_acrObject (readonly)

Returns the value of attribute requested_acr.



7
8
9
# File 'app/models/sign_in/credential_level.rb', line 7

def requested_acr
  @requested_acr
end

Instance Method Details

#can_uplevel_credential?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/sign_in/credential_level.rb', line 31

def can_uplevel_credential?
  requested_acr == Constants::Auth::MIN && current_ial < max_ial
end

#max_ial_greater_than_or_equal_to_current_ialObject (private)



41
42
43
# File 'app/models/sign_in/credential_level.rb', line 41

def max_ial_greater_than_or_equal_to_current_ial
  errors.add(:max_ial, 'cannot be less than Current ial') if max_ial.to_i < current_ial.to_i
end

#persisted?Boolean (private)

Returns:

  • (Boolean)


37
38
39
# File 'app/models/sign_in/credential_level.rb', line 37

def persisted?
  false
end