Description:
[web] temporary fixed on problem of reloading Configuration, when there are many mongrel processes git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@164 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r83:092dd4df7102 - - 1 file changed: 1 inserted, 0 deleted

@@ -3,48 +3,49
3 3
4 4 class ApplicationController < ActionController::Base
5 5 # Pick a unique cookie name to distinguish our session data from others'
6 6 session :session_key => '_grader_session_id'
7 7
8 8 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
9 9
10 10 def authorization_by_roles(allowed_roles)
11 11 return false unless authenticate
12 12 user = User.find(session[:user_id])
13 13 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
14 14 flash[:notice] = 'You are not authorized to view the page you requested'
15 15 redirect_to :controller => 'main', :action => 'login'
16 16 return false
17 17 end
18 18 end
19 19
20 20 protected
21 21 def authenticate
22 22 unless session[:user_id]
23 23 redirect_to :controller => 'main', :action => 'login'
24 24 return false
25 25 end
26 26
27 + Configuration.reload
27 28 # check if run in single user mode
28 29 if (Configuration[SINGLE_USER_MODE_CONF_KEY])
29 30 user = User.find(session[:user_id])
30 31 if user==nil or user.login != 'root'
31 32 redirect_to :controller => 'main', :action => 'login'
32 33 return false
33 34 end
34 35 end
35 36
36 37 return true
37 38 end
38 39
39 40 def authorization
40 41 return false unless authenticate
41 42 user = User.find(session[:user_id])
42 43 unless user.roles.detect { |role|
43 44 role.rights.detect{ |right|
44 45 right.controller == self.class.controller_name and
45 46 (right.action == 'all' or right.action == action_name)
46 47 }
47 48 }
48 49 flash[:notice] = 'You are not authorized to view the page you requested'
49 50 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
50 51 redirect_to :controller => 'main', :action => 'login'
You need to be logged in to leave comments. Login now