Sha256: 6edbda3a4de434ba1afcfbf5847c1fe90949808cb458a3d71bd77584567bc410

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

class Auth::NewPasswordForm < ApplicationForm
  attr_accessor :token, :password, :password_confirmation

  validates :token, presence: true
  validates :password, presence: true, confirmation: true, length: { minimum: 8 }

  def reset?
    return false if invalid?

    user = User.find_by_token_for(:password_reset, token)

    if user.nil?
      errors.add(:password, message: 'This password reset token is invalid.')
      return false
    end

    user.update(password: password)

    true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaze-0.7.0 stubs/default/app/forms/auth/new_password_form.rb
kaze-0.6.0 stubs/default/app/forms/auth/new_password_form.rb
kaze-0.5.0 stubs/default/app/forms/auth/new_password_form.rb