Module: Masks::Credentials::Factor2

Extended by:
ActiveSupport::Concern
Included in:
BackupCode, OneTimeCode
Defined in:
app/models/masks/credentials/factor2.rb

Overview

Base class for factor2 credentials.

Instance Method Summary collapse

Instance Method Details

#enable(code, secret:) ⇒ Object

Raises:

  • (NotImplementedError)


54
55
56
# File 'app/models/masks/credentials/factor2.rb', line 54

def enable(code, secret:)
  raise NotImplementedError
end

#enabled?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/masks/credentials/factor2.rb', line 42

def enabled?
  secret.present?
end

#generate_secretObject



66
67
68
# File 'app/models/masks/credentials/factor2.rb', line 66

def generate_secret
  nil
end

#lookupObject



18
19
20
# File 'app/models/masks/credentials/factor2.rb', line 18

def lookup
  # nothing to do here
end

#maskupObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/masks/credentials/factor2.rb', line 22

def maskup
  check.optional = false if actor&.factor2?

  return unless enabled?

  code_param = session_params&.fetch(param, nil)&.presence

  self.code = verify(code_param) if code_param

  if code
    approve!
  elsif code_param
    deny!
  end
end

#paramObject

Raises:

  • (NotImplementedError)


46
47
48
# File 'app/models/masks/credentials/factor2.rb', line 46

def param
  raise NotImplementedError
end

#secretObject

Raises:

  • (NotImplementedError)


50
51
52
# File 'app/models/masks/credentials/factor2.rb', line 50

def secret
  raise NotImplementedError
end

#verified?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/masks/credentials/factor2.rb', line 38

def verified?
  code
end

#verify(code) ⇒ Object

Raises:

  • (NotImplementedError)


58
59
60
# File 'app/models/masks/credentials/factor2.rb', line 58

def verify(code)
  raise NotImplementedError
end

#verify_on_enable?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/masks/credentials/factor2.rb', line 62

def verify_on_enable?
  false
end