Description:
merge
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r838:f3c1c942cc51 - - 2 files changed: 5 inserted, 3 deleted

@@ -31,14 +31,13
31 end
31 end
32 return true
32 return true
33 end
33 end
34
34
35 def authorization_by_roles(allowed_roles)
35 def authorization_by_roles(allowed_roles)
36 return false unless check_valid_login
36 return false unless check_valid_login
37 - user = User.find(session[:user_id])
37 + unless @current_user.roles.detect { |role| allowed_roles.member?(role.name) }
38 - unless user.roles.detect { |role| allowed_roles.member?(role.name) }
39 unauthorized_redirect
38 unauthorized_redirect
40 return false
39 return false
41 end
40 end
42 end
41 end
43
42
44 def testcase_authorization
43 def testcase_authorization
@@ -1,9 +1,12
1 class ProblemsController < ApplicationController
1 class ProblemsController < ApplicationController
2
2
3 - before_action :admin_authorization
3 + before_action :admin_authorization, except: [:stat]
4 + before_action only: [:stat] do
5 + authorization_by_roles(['admin','ta'])
6 + end
4
7
5 in_place_edit_for :problem, :name
8 in_place_edit_for :problem, :name
6 in_place_edit_for :problem, :full_name
9 in_place_edit_for :problem, :full_name
7 in_place_edit_for :problem, :full_score
10 in_place_edit_for :problem, :full_score
8
11
9 def index
12 def index
You need to be logged in to leave comments. Login now