module Devise::Models::Recoverable::ClassMethods

def reset_password_by_token(attributes={})

Attributes must contain reset_password_token, password and confirmation
containing an error in reset_password_token attribute.
try saving the record. If not user is found, returns a new user
password. If a user is found, reset it's password and automatically
Attempt to find a user by it's reset_password_token to reset it's
def reset_password_by_token(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

def send_reset_password_instructions(attributes={})

Attributes must contain the user email
with an email not found error.
password instructions to it. If not user is found, returns a new user
Attempt to find a user by it's email. If a record is found, send new
def send_reset_password_instructions(attributes={})
  recoverable = find_or_initialize_with_error_by(:email, attributes[:email], :not_found)
  recoverable.send_reset_password_instructions unless recoverable.new_record?
  recoverable
end