]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3679 Make the password checking consistent between the "My Profile" and "Users...
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 11 Aug 2014 08:01:03 +0000 (10:01 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 11 Aug 2014 08:01:03 +0000 (10:01 +0200)
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/account_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index a90cd7539b2b5d799164451edeed196f4ab8bddf..828d0f3f840b5bcc481feb888080048f36c11944 100644 (file)
@@ -43,17 +43,12 @@ class AccountController < ApplicationController
   def change_password
     verify_post_request
     if User.authenticate(current_user.login, params[:old_password], servlet_request)
-      if ((params[:password] == params[:password_confirmation]))
-        current_user.password = params[:password]
-        current_user.password_confirmation = params[:password]
-        @result = current_user.save
-        if @result
-          flash[:notice] = message('my_profile.password.changed')
-        else
-          flash[:error] = message('my_profile.password.empty')
-        end
+      if params[:password].blank?
+        flash[:error] = message('my_profile.password.empty')
+      elsif current_user.update_attributes(:password => params[:password], :password_confirmation => params[:password_confirmation])
+        flash[:notice] = message('my_profile.password.changed')
       else
-        flash[:error] = message('my_profile.password.mismatch')
+        flash[:error] = current_user.errors.full_messages.join("<br/>\n")
       end
     else
       flash[:error] = message('my_profile.password.wrong_old')
index 11e17ff729eff2aa93a4c410688379380ed35f80..ba549b36f7b07bc21143db6bbbcc25882f604567 100644 (file)
@@ -120,7 +120,7 @@ class UsersController < ApplicationController
     user = User.find(params[:id])
     @user = user
     if params[:user][:password].blank?
-      @errors = 'Password required.'
+      @errors = message('my_profile.password.empty')
       render :partial => 'users/change_password_form', :status => 400
     elsif user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
       flash[:notice] = 'Password was successfully updated.'
index 15d31e7e06cb68497c4d9cb8a3051625b20548e3..96d85b86381f4a0e3a2d288bf1ebbb9b7ed89599 100644 (file)
@@ -1926,7 +1926,6 @@ my_profile.password.confirm=Confirm new value
 my_profile.password.submit=Change password
 my_profile.password.changed=Password changed
 my_profile.password.empty=Password can not be empty
-my_profile.password.mismatch=Password mismatch
 my_profile.password.wrong_old=Wrong old password
 my_profile.notifications.submit=Save changes
 my_profile.overall_notifications.title=Overall notifications