Show More
Commit Description:
MERGE changeset 306:307 from branch ytopc08-2 that fixes migration bug...
Commit Description:
MERGE changeset 306:307 from branch ytopc08-2 that fixes migration bug
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@308 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/controllers/login_controller.rb
| 43 lines
| 1.1 KiB
| text/x-ruby
| RubyLexer
|
|
r0 | class LoginController < ApplicationController | ||
def index | ||||
# show login screen | ||||
reset_session | ||||
redirect_to :controller => 'main', :action => 'login' | ||||
end | ||||
def login | ||||
if user = User.authenticate(params[:login], params[:password]) | ||||
session[:user_id] = user.id | ||||
redirect_to :controller => 'main', :action => 'list' | ||||
|
r104 | if user.admin? | ||
session[:admin] = true | ||||
else | ||||
session[:admin] = false | ||||
end | ||||
|
r0 | else | ||
flash[:notice] = 'Wrong password' | ||||
redirect_to :controller => 'main', :action => 'login' | ||||
end | ||||
end | ||||
|
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 | ||||
if site.password == params[:login][:password] | ||||
session[:site_id] = site.id | ||||
redirect_to :controller => 'site', :action => 'index' | ||||
else | ||||
flash[:notice] = 'Wrong site password' | ||||
redirect_to :controller => 'main', :action => 'login' | ||||
end | ||||
end | ||||
|
r0 | end | ||