Show More
Commit Description:
use uuid cookie
Commit Description:
use uuid cookie
File last commit:
Show/Diff file:
Action:
app/controllers/login_controller.rb | 99 lines | 2.5 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 class LoginController < ApplicationController
Jittat Fakcharoenphol
authenticates through programming.in.th
r770 @@authenticators = []
pramook
initial commit...
r0 def index
# show login screen
reset_session
redirect_to :controller => 'main', :action => 'login'
end
def login
Jittat Fakcharoenphol
authenticates through programming.in.th
r770 user = get_authenticated_user(params[:login], params[:password])
add datatable...
r691 unless user
flash[:notice] = 'Wrong password'
redirect_to :controller => 'main', :action => 'login'
return
end
if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree]) and !user.admin?
add license agreement checkbox
r535 flash[:notice] = 'You must accept the agreement before logging in'
redirect_to :controller => 'main', :action => 'login'
add datatable...
r691 return
end
use uuid cookie
r852 #store uuid when login
if user.last_ip.nil?
user.last_ip = cookies[:uuid]
else
if user.last_ip != cookies[:uuid]
user.last_ip =cookies[:uuid]
#log different login
end
end
add datatable...
r691 #process logging in
session[:user_id] = user.id
session[:admin] = user.admin?
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
add datatable...
r691 # clear forced logout flag for multicontests contest change
if GraderConfiguration.multicontests?
contest_stat = user.contest_stat
if contest_stat.respond_to? :forced_logout
if contest_stat.forced_logout
contest_stat.forced_logout = false
contest_stat.save
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295 end
end
add datatable...
r691 end
add login stat
r410
add datatable...
r691 #save login information
use uuid cookie
r852 Login.create(user_id: user.id, ip_address: cookies[:uuid])
add datatable...
r691
redirect_to :controller => 'main', :action => 'list'
pramook
initial commit...
r0 end
jittat
[web] site start/stop supports...
r123 def site_login
begin
site = Site.find(params[:login][:site_id])
rescue ActiveRecord::RecordNotFound
site = nil
end
if site==nil
flash[:notice] = 'Wrong site'
redirect_to :controller => 'main', :action => 'login' and return
end
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 if (site.password) and (site.password == params[:login][:password])
jittat
[web] site start/stop supports...
r123 session[:site_id] = site.id
redirect_to :controller => 'site', :action => 'index'
else
flash[:notice] = 'Wrong site password'
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 redirect_to :controller => 'site', :action => 'login'
jittat
[web] site start/stop supports...
r123 end
end
- more test on user admin and authorization...
r754 def logout
redirect_to root_path
end
Jittat Fakcharoenphol
authenticates through programming.in.th
r770 def self.add_authenticator(authenticator)
@@authenticators << authenticator
end
protected
def get_authenticated_user(login, password)
if @@authenticators.empty?
return User.authenticate(login, password)
else
Jittat Fakcharoenphol
allows local users
r771 user = User.authenticate(login, password)
Jittat Fakcharoenphol
authenticates through programming.in.th
r770 @@authenticators.each do |authenticator|
if not user
user = authenticator.authenticate(login, password)
end
end
return user
end
end
pramook
initial commit...
r0 end