Class: StandardId::Web::ResetPasswordConfirmForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model, PasswordStrength
Defined in:
app/forms/standard_id/web/reset_password_confirm_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(password_credential, params = {}) ⇒ ResetPasswordConfirmForm

Returns a new instance of ResetPasswordConfirmForm.



17
18
19
20
# File 'app/forms/standard_id/web/reset_password_confirm_form.rb', line 17

def initialize(password_credential, params = {})
  @password_credential = password_credential
  super(params)
end

Instance Attribute Details

#password_credentialObject (readonly)

Returns the value of attribute password_credential.



11
12
13
# File 'app/forms/standard_id/web/reset_password_confirm_form.rb', line 11

def password_credential
  @password_credential
end

Instance Method Details

#submitObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/forms/standard_id/web/reset_password_confirm_form.rb', line 22

def submit
  return false unless valid?

  ActiveRecord::Base.transaction do
    @password_credential.update!(password: password, password_confirmation: password_confirmation)
    @password_credential..sessions.destroy_all
  end

  true
rescue ActiveRecord::RecordInvalid => e
  errors.add(:base, e.record.errors.full_messages.join(", "))
  false
end