Method: Devise::Models::Recoverable::ClassMethods#reset_password!

Defined in:
lib/devise/models/recoverable.rb

#reset_password!(attributes = {}) ⇒ Object

Attempt to find a user by it’s reset_password_token to reset it’s password. If a user is found, reset it’s password and automatically try saving the record. If not user is found, returns a new user containing an error in reset_password_token attribute. Attributes must contain reset_password_token, password and confirmation



72
73
74
75
76
# File 'lib/devise/models/recoverable.rb', line 72

def reset_password!(attributes={})
  recoverable = find_or_initialize_with_error_by(:reset_password_token, attributes[:reset_password_token])
  recoverable.reset_password!(attributes[:password], attributes[:password_confirmation]) unless recoverable.new_record?
  recoverable
end