Adding find and reset password method to recoverable

This commit is contained in:
Carlos A. da Silva
2009-09-18 10:47:12 -03:00
parent 7f77b4ae40
commit 91b19bd44f
2 changed files with 46 additions and 2 deletions

View File

@@ -42,6 +42,16 @@ module Devise
end
recoverable
end
def find_and_reset_password(perishable_token, password=nil, password_confirmation=nil)
recoverable = find_or_initialize_by_perishable_token(perishable_token)
unless recoverable.new_record?
recoverable.reset_password!(password, password_confirmation)
else
recoverable.errors.add(:perishable_token, :invalid, :default => "invalid confirmation")
end
recoverable
end
end
end
end