Description:
allows local users
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r771:15215b7e2423 - - 1 file changed: 1 inserted, 1 deleted
@@ -27,59 +27,59 | |||||
|
27 | session[:admin] = user.admin? |
|
27 | session[:admin] = user.admin? |
|
28 |
|
28 | ||
|
29 | # clear forced logout flag for multicontests contest change |
|
29 | # clear forced logout flag for multicontests contest change |
|
30 | if GraderConfiguration.multicontests? |
|
30 | if GraderConfiguration.multicontests? |
|
31 | contest_stat = user.contest_stat |
|
31 | contest_stat = user.contest_stat |
|
32 | if contest_stat.respond_to? :forced_logout |
|
32 | if contest_stat.respond_to? :forced_logout |
|
33 | if contest_stat.forced_logout |
|
33 | if contest_stat.forced_logout |
|
34 | contest_stat.forced_logout = false |
|
34 | contest_stat.forced_logout = false |
|
35 | contest_stat.save |
|
35 | contest_stat.save |
|
36 | end |
|
36 | end |
|
37 | end |
|
37 | end |
|
38 | end |
|
38 | end |
|
39 |
|
39 | ||
|
40 | #save login information |
|
40 | #save login information |
|
41 | Login.create(user_id: user.id, ip_address: request.remote_ip) |
|
41 | Login.create(user_id: user.id, ip_address: request.remote_ip) |
|
42 |
|
42 | ||
|
43 | redirect_to :controller => 'main', :action => 'list' |
|
43 | redirect_to :controller => 'main', :action => 'list' |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
46 | def site_login |
|
46 | def site_login |
|
47 | begin |
|
47 | begin |
|
48 | site = Site.find(params[:login][:site_id]) |
|
48 | site = Site.find(params[:login][:site_id]) |
|
49 | rescue ActiveRecord::RecordNotFound |
|
49 | rescue ActiveRecord::RecordNotFound |
|
50 | site = nil |
|
50 | site = nil |
|
51 | end |
|
51 | end |
|
52 | if site==nil |
|
52 | if site==nil |
|
53 | flash[:notice] = 'Wrong site' |
|
53 | flash[:notice] = 'Wrong site' |
|
54 | redirect_to :controller => 'main', :action => 'login' and return |
|
54 | redirect_to :controller => 'main', :action => 'login' and return |
|
55 | end |
|
55 | end |
|
56 | if (site.password) and (site.password == params[:login][:password]) |
|
56 | if (site.password) and (site.password == params[:login][:password]) |
|
57 | session[:site_id] = site.id |
|
57 | session[:site_id] = site.id |
|
58 | redirect_to :controller => 'site', :action => 'index' |
|
58 | redirect_to :controller => 'site', :action => 'index' |
|
59 | else |
|
59 | else |
|
60 | flash[:notice] = 'Wrong site password' |
|
60 | flash[:notice] = 'Wrong site password' |
|
61 | redirect_to :controller => 'site', :action => 'login' |
|
61 | redirect_to :controller => 'site', :action => 'login' |
|
62 | end |
|
62 | end |
|
63 | end |
|
63 | end |
|
64 |
|
64 | ||
|
65 | def self.add_authenticator(authenticator) |
|
65 | def self.add_authenticator(authenticator) |
|
66 | @@authenticators << authenticator |
|
66 | @@authenticators << authenticator |
|
67 | end |
|
67 | end |
|
68 |
|
68 | ||
|
69 | protected |
|
69 | protected |
|
70 |
|
70 | ||
|
71 | def get_authenticated_user(login, password) |
|
71 | def get_authenticated_user(login, password) |
|
72 | if @@authenticators.empty? |
|
72 | if @@authenticators.empty? |
|
73 | return User.authenticate(login, password) |
|
73 | return User.authenticate(login, password) |
|
74 | else |
|
74 | else |
|
75 | - user = nil |
|
75 | + user = User.authenticate(login, password) |
|
76 | @@authenticators.each do |authenticator| |
|
76 | @@authenticators.each do |authenticator| |
|
77 | if not user |
|
77 | if not user |
|
78 | user = authenticator.authenticate(login, password) |
|
78 | user = authenticator.authenticate(login, password) |
|
79 | end |
|
79 | end |
|
80 | end |
|
80 | end |
|
81 | return user |
|
81 | return user |
|
82 | end |
|
82 | end |
|
83 | end |
|
83 | end |
|
84 |
|
84 | ||
|
85 | end |
|
85 | end |
You need to be logged in to leave comments.
Login now