Class: StandardId::Web::ResetPasswordStartForm

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ResetPasswordStartForm

Constructor accepts the reset URL template so the form is decoupled from routing. The controller builds a URL from ‘reset_password_confirm_url` (or a request-derived fallback) and appends a literal `?token=token` (or `&token=token`) marker via string concatenation. The delivery job substitutes that placeholder with the actual token after account lookup.



16
17
18
19
# File 'app/forms/standard_id/web/reset_password_start_form.rb', line 16

def initialize(attributes = {})
  @reset_url_template = attributes.delete(:reset_url_template) if attributes.is_a?(Hash)
  super
end

Instance Attribute Details

#reset_url_templateObject (readonly)

Returns the value of attribute reset_url_template.



21
22
23
# File 'app/forms/standard_id/web/reset_password_start_form.rb', line 21

def reset_url_template
  @reset_url_template
end

Instance Method Details

#submitObject



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

def submit
  return false unless valid?

  # Enqueue the full lookup + token generation + mailer delivery pipeline
  # so the controller response time does not depend on whether an account
  # exists for the submitted email. This closes the user-enumeration
  # timing side channel.
  StandardId::PasswordResetDeliveryJob.perform_later(
    email: email.to_s,
    reset_url_template: reset_url_template.to_s
  )

  true
end