Patch #3858 » force_admin_password_change.diff
app/controllers/my_controller.rb (working copy) | ||
---|---|---|
77 | 77 |
# Manage user's password |
78 | 78 |
def password |
79 | 79 |
@user = User.current |
80 |
if @user.check_password?('admin') |
|
81 |
flash[:notice] = l(:notice_change_default_password) |
|
82 |
end |
|
80 | 83 |
flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id |
81 | 84 |
if request.post? |
82 | 85 |
if @user.check_password?(params[:password]) |
83 | 86 |
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
87 |
if @user.password == "admin" |
|
88 |
flash[:error] = l(:notice_password_other_than_admin) |
|
89 |
end |
|
84 | 90 |
if @user.save |
85 | 91 |
flash[:notice] = l(:notice_account_password_updated) |
86 | 92 |
redirect_to :action => 'account' |
app/controllers/account_controller.rb (working copy) | ||
---|---|---|
56 | 56 |
session[:auth_source_registration] = {:login => user.login, :auth_source_id => user.auth_source_id } |
57 | 57 |
render :action => 'register' |
58 | 58 |
else |
59 |
# Valid user |
|
60 |
self.logged_user = user |
|
61 |
# generate a key and set cookie if autologin |
|
62 |
if params[:autologin] && Setting.autologin? |
|
63 |
token = Token.create(:user => user, :action => 'autologin') |
|
64 |
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now } |
|
59 |
if params[:username] == "admin" && params[:password] == "admin" |
|
60 |
self.logged_user = user |
|
61 |
call_hook(:controller_account_success_authentication_after, {:user => user }) |
|
62 |
redirect_to :controller => 'my', :action => 'password' |
|
63 |
else |
|
64 |
# Valid user |
|
65 |
self.logged_user = user |
|
66 |
# generate a key and set cookie if autologin |
|
67 |
if params[:autologin] && Setting.autologin? |
|
68 |
token = Token.create(:user => user, :action => 'autologin') |
|
69 |
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now } |
|
70 |
end |
|
71 |
call_hook(:controller_account_success_authentication_after, {:user => user }) |
|
72 |
redirect_back_or_default :controller => 'my', :action => 'page' |
|
65 | 73 |
end |
66 |
call_hook(:controller_account_success_authentication_after, {:user => user }) |
|
67 |
redirect_back_or_default :controller => 'my', :action => 'page' |
|
68 | 74 |
end |
69 | 75 |
end |
70 | 76 |
end |
lang/en.yml (working copy) | ||
---|---|---|
78 | 78 |
notice_account_pending: "Your account was created and is now pending administrator approval." |
79 | 79 |
notice_default_data_loaded: Default configuration successfully loaded. |
80 | 80 |
notice_unable_delete_version: Unable to delete version. |
81 |
notice_change_default_password: Please change the default password. |
|
82 |
notice_password_other_than_admin: Please select a password other than the default password. |
|
81 | 83 | |
82 | 84 |
error_can_t_load_default_data: "Default configuration could not be loaded: %s" |
83 | 85 |
error_scm_not_found: "The entry or revision was not found in the repository." |