|
|
@ -1,4 +1,4 @@
|
|
|
|
# Redmine - project management software
|
|
|
|
# Redmine - project management software
|
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
@ -50,19 +50,34 @@ class MyController < ApplicationController
|
|
|
|
def account
|
|
|
|
def account
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
@pref = @user.pref
|
|
|
|
@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?
|
|
|
|
if request.post?
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
@user.pref.attributes = params[:pref]
|
|
|
|
@user.pref.attributes = params[:pref]
|
|
|
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
|
|
|
@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
|
|
|
|
if @user.save
|
|
|
|
@user.pref.save
|
|
|
|
@user.pref.save
|
|
|
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
|
|
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
|
|
|
set_language_if_valid @user.language
|
|
|
|
set_language_if_valid @user.language
|
|
|
|
@user.update_user_extensions()
|
|
|
|
|
|
|
|
flash[:notice] = l(:notice_account_updated)
|
|
|
|
flash[:notice] = l(:notice_account_updated)
|
|
|
|
redirect_to user_path(@user) #modified by huang/ my_account_path
|
|
|
|
redirect_to user_path(@user)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -88,9 +103,7 @@ class MyController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
# Manage user's password
|
|
|
|
# Manage user's password
|
|
|
|
def password
|
|
|
|
def password
|
|
|
|
@root_path="/home/pdl/redmine-2.3.2-0/apache2/"
|
|
|
|
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
@middle = "^"+@user.login.to_s+":"
|
|
|
|
|
|
|
|
unless @user.change_password_allowed?
|
|
|
|
unless @user.change_password_allowed?
|
|
|
|
flash[:error] = l(:notice_can_t_change_password)
|
|
|
|
flash[:error] = l(:notice_can_t_change_password)
|
|
|
|
redirect_to my_account_path
|
|
|
|
redirect_to my_account_path
|
|
|
@ -99,8 +112,6 @@ class MyController < ApplicationController
|
|
|
|
if request.post?
|
|
|
|
if request.post?
|
|
|
|
if @user.check_password?(params[:password])
|
|
|
|
if @user.check_password?(params[:password])
|
|
|
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
|
|
|
@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
|
|
|
|
if @user.save
|
|
|
|
flash[:notice] = l(:notice_account_password_updated)
|
|
|
|
flash[:notice] = l(:notice_account_password_updated)
|
|
|
|
redirect_to my_account_path
|
|
|
|
redirect_to my_account_path
|
|
|
|