When email change fails, give appropriate error message

Previously it would always say "Password was incorrect" on failure,
whether that was the actual problem or not.
This commit is contained in:
Toks
2014-01-24 13:52:43 -05:00
parent d49571226c
commit 744daa6c0c
3 changed files with 7 additions and 6 deletions

View File

@@ -6,11 +6,12 @@ module Maintenance
def create
email_change = UserEmailChange.new(CurrentUser.user, params[:email_change][:email], params[:email_change][:password])
if email_change.process
redirect_to(edit_user_path(CurrentUser.user.id), :notice => "Email was updated")
email_change.process
if CurrentUser.user.errors.any?
flash[:notice] = CurrentUser.user.errors.full_messages.join("; ")
redirect_to(new_maintenance_user_email_change_path)
else
flash[:notice] = "Password was incorrect"
render :action => "new"
redirect_to(edit_user_path(CurrentUser.user.id), :notice => "Email was updated")
end
end
end