Project

General

Profile

Patch #3858 » force_admin_password_change.diff

Diff file for trunk/dev version. - Ian Wilson, 2009-09-13 03:35

View differences:

app/controllers/my_controller.rb (working copy)
# Manage user's password
def password
@user = User.current
if @user.check_password?('admin')
flash[:notice] = l(:notice_change_default_password)
end
flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
if request.post?
if @user.check_password?(params[:password])
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if @user.password == "admin"
flash[:error] = l(:notice_password_other_than_admin)
end
if @user.save
flash[:notice] = l(:notice_account_password_updated)
redirect_to :action => 'account'
app/controllers/account_controller.rb (working copy)
session[:auth_source_registration] = {:login => user.login, :auth_source_id => user.auth_source_id }
render :action => 'register'
else
# Valid user
self.logged_user = user
# generate a key and set cookie if autologin
if params[:autologin] && Setting.autologin?
token = Token.create(:user => user, :action => 'autologin')
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
if params[:username] == "admin" && params[:password] == "admin"
self.logged_user = user
call_hook(:controller_account_success_authentication_after, {:user => user })
redirect_to :controller => 'my', :action => 'password'
else
# Valid user
self.logged_user = user
# generate a key and set cookie if autologin
if params[:autologin] && Setting.autologin?
token = Token.create(:user => user, :action => 'autologin')
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
end
call_hook(:controller_account_success_authentication_after, {:user => user })
redirect_back_or_default :controller => 'my', :action => 'page'
end
call_hook(:controller_account_success_authentication_after, {:user => user })
redirect_back_or_default :controller => 'my', :action => 'page'
end
end
end
lang/en.yml (working copy)
notice_account_pending: "Your account was created and is now pending administrator approval."
notice_default_data_loaded: Default configuration successfully loaded.
notice_unable_delete_version: Unable to delete version.
notice_change_default_password: Please change the default password.
notice_password_other_than_admin: Please select a password other than the default password.
error_can_t_load_default_data: "Default configuration could not be loaded: %s"
error_scm_not_found: "The entry or revision was not found in the repository."
(1-1/2)