Module: Devise::Models::Recoverable::ClassMethods

Defined in:
lib/protected/devise_recoverable_extensions.rb

Instance Method Summary collapse

Instance Method Details

#reset_password_by_token(attributes = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/protected/devise_recoverable_extensions.rb', line 5

def reset_password_by_token(attributes={})
  recoverable = find_or_initialize_with_error_by(:reset_password_token, attributes[:reset_password_token])
  if recoverable.persisted?
    recoverable.reset_password!(attributes[:password], attributes[:password_confirmation])
    if recoverable.errors.empty?
      recoverable.failed_attempts = 0
      recoverable.save(:validate => false)
    end
  end
  recoverable
end