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:
@@ -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
|
||||
|
||||
@@ -9,7 +9,7 @@ class UserEmailChange
|
||||
|
||||
def process
|
||||
if User.authenticate(user.name, password).nil?
|
||||
false
|
||||
user.errors[:base] << "Password was incorrect"
|
||||
else
|
||||
user.email = new_email
|
||||
user.save
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<h1>Settings</h1>
|
||||
|
||||
<%= simple_form_for @user do |f| %>
|
||||
<h2 id="edit-options"><%= link_to "Basic settings", "#basic-settings", :class => 'active' %> | <%= link_to "Advanced settings", "#advanced-settings" %> | <%= link_to "Change password", "#change-password" %> | <%= link_to "Delete account", maintenance_user_deletion_path, :id => "delete-account" %></h2>
|
||||
<h2 id="edit-options"><%= link_to "Basic settings", "#basic-settings", :class => "active" %> | <%= link_to "Advanced settings", "#advanced-settings" %> | <%= link_to "Change password", "#change-password" %> | <%= link_to "Delete account", maintenance_user_deletion_path, :id => "delete-account" %></h2>
|
||||
|
||||
<fieldset id="basic-settings-section">
|
||||
<div class="input">
|
||||
|
||||
Reference in New Issue
Block a user