Description:
allow ta to view problem stat
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r803:30dd5b343f6b - - 2 files changed: 5 inserted, 3 deleted
@@ -31,14 +31,13 | |||
|
31 | 31 | end |
|
32 | 32 | return true |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def authorization_by_roles(allowed_roles) |
|
36 | 36 | return false unless check_valid_login |
|
37 | - user = User.find(session[:user_id]) | |
|
38 | - unless user.roles.detect { |role| allowed_roles.member?(role.name) } | |
|
37 | + unless @current_user.roles.detect { |role| allowed_roles.member?(role.name) } | |
|
39 | 38 | unauthorized_redirect |
|
40 | 39 | return false |
|
41 | 40 | end |
|
42 | 41 | end |
|
43 | 42 | |
|
44 | 43 | def testcase_authorization |
@@ -1,9 +1,12 | |||
|
1 | 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 | 8 | in_place_edit_for :problem, :name |
|
6 | 9 | in_place_edit_for :problem, :full_name |
|
7 | 10 | in_place_edit_for :problem, :full_score |
|
8 | 11 | |
|
9 | 12 | def index |
You need to be logged in to leave comments.
Login now