|
|
|
@ -248,6 +248,23 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
def authorize1(ctrl = params[:controller], action = params[:action],login = params[:user_name],pwd = params[:password], global = false)
|
|
|
|
|
#modify by NWB
|
|
|
|
|
if(!User.current.logged? && !login.nil?)
|
|
|
|
|
password_authentication
|
|
|
|
|
end
|
|
|
|
|
allowed = authorize_allowed(params[:controller], params[:action],global)
|
|
|
|
|
|
|
|
|
|
if allowed
|
|
|
|
|
true
|
|
|
|
|
else
|
|
|
|
|
if @project && @project.archived?
|
|
|
|
|
render_403 :message => :notice_not_authorized_archived_project
|
|
|
|
|
else
|
|
|
|
|
deny_access
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false)
|
|
|
|
|
#modify by NWB
|
|
|
|
@ -789,4 +806,28 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
@organizer = WebFooterOranizer.first
|
|
|
|
|
@companies = WebFooterCompany.all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def password_authentication
|
|
|
|
|
user, last_login_on = User.try_to_login(params[:user_name], params[:password])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
successful_authentication(user, last_login_on)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def successful_authentication(user, last_login_on)
|
|
|
|
|
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
|
|
|
|
|
# Valid user
|
|
|
|
|
self.logged_user = user
|
|
|
|
|
# generate a key and set cookie if autologin
|
|
|
|
|
if params[:autologin] && Setting.autologin?
|
|
|
|
|
set_autologin_cookie(user)
|
|
|
|
|
end
|
|
|
|
|
call_hook(:controller_account_success_authentication_after, {:user => user })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|