Class: LinkedRails::Auth::OtpAttempt

Inherits:
OtpBase
  • Object
show all
Defined in:
app/models/linked_rails/auth/otp_attempt.rb

Instance Attribute Summary

Attributes inherited from OtpBase

#encoded_session, #otp_attempt

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OtpBase

iri_template, owner_for_otp, #singular_iri_opts, singular_iri_template

Methods included from OtpHelper

#handle_expired_session, #owner_from_session, #session_from_param

Class Method Details

.form_classObject



21
22
23
# File 'app/models/linked_rails/auth/otp_attempt.rb', line 21

def form_class
  LinkedRails.otp_attempt_form_class
end

.requested_singular_resource(params, user_context) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/models/linked_rails/auth/otp_attempt.rb', line 29

def requested_singular_resource(params, user_context)
  owner = owner_for_otp(params, user_context)
  return if owner.blank?

  attempt = LinkedRails.otp_attempt_class.find_by(owner: owner) || LinkedRails.otp_attempt_class.new
  attempt.encoded_session = params[:session]
  attempt
end

.singular_route_keyObject



25
26
27
# File 'app/models/linked_rails/auth/otp_attempt.rb', line 25

def singular_route_key
  'u/otp_attempt'
end

Instance Method Details

#raise_on_persisting(**_opts) ⇒ Object



6
7
8
# File 'app/models/linked_rails/auth/otp_attempt.rb', line 6

def raise_on_persisting(**_opts)
  raise "#{self.class.name} should not be persisted"
end

#saveObject



14
15
16
17
18
# File 'app/models/linked_rails/auth/otp_attempt.rb', line 14

def save
  validate_otp_attempt

  errors.empty?
end