diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 4a4e0693..6541ed2c 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -1,4 +1,4 @@ -# Redmine - project management software + # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or @@ -50,19 +50,34 @@ class MyController < ApplicationController def account @user = User.current @pref = @user.pref - + #Modified by young + unless @user.change_password_allowed? + flash[:error] = l(:notice_can_t_change_password) + redirect_to my_account_path + return + end + #Ended by young if request.post? @user.safe_attributes = params[:user] @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') - + #Added by young + if @user.check_password?(params[:password]) + @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] + if @user.save + flash[:notice] = l(:notice_account_password_updated) + # redirect_to my_account_path + end + else + flash[:error] = l(:notice_account_wrong_password) + end + #Ended by young if @user.save @user.pref.save @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) set_language_if_valid @user.language - @user.update_user_extensions() flash[:notice] = l(:notice_account_updated) - redirect_to user_path(@user) #modified by huang/ my_account_path + redirect_to user_path(@user) return end end @@ -88,9 +103,7 @@ class MyController < ApplicationController # Manage user's password def password - @root_path="/home/pdl/redmine-2.3.2-0/apache2/" @user = User.current - @middle = "^"+@user.login.to_s+":" unless @user.change_password_allowed? flash[:error] = l(:notice_can_t_change_password) redirect_to my_account_path @@ -99,8 +112,6 @@ class MyController < ApplicationController if request.post? if @user.check_password?(params[:password]) @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] - system "sed -i /"+@middle+"/{d} "+@root_path+"user.passwd" - system "htpasswd -mb "+@root_path+"user.passwd "+@user.login.to_s+" "+params[:new_password] if @user.save flash[:notice] = l(:notice_account_password_updated) redirect_to my_account_path diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 721b5e3b..45034667 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -80,7 +80,16 @@
- + + +