Cleaning up recoverable methods, changing to use a hash of options instead of default parameters.

This commit is contained in:
Carlos A. da Silva
2009-10-07 22:33:45 -03:00
parent 37de41725c
commit cf1ea9ab86
4 changed files with 25 additions and 20 deletions

View File

@@ -5,8 +5,8 @@ class PasswordsController < ApplicationController
end
def create
@password = User.find_and_send_reset_password_instructions(params[:password][:email])
if !@password.new_record?
@password = User.send_reset_password_instructions(params[:password])
if @password.errors.empty?
flash[:notice] = 'You will receive an email with instructions about how to reset your password in a few minutes.'
redirect_to new_session_path
else
@@ -20,8 +20,7 @@ class PasswordsController < ApplicationController
end
def update
@password = User.find_and_reset_password(params[:password][:perishable_token],
params[:password][:password], params[:password][:password_confirmation])
@password = User.reset_password(params[:password])
if @password.errors.empty?
flash[:notice] = 'Your password was changed successfully.'
redirect_to new_session_path