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
@@ -34,8 +34,7 | |||
|
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 |
@@ -1,6 +1,9 | |||
|
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 |
You need to be logged in to leave comments.
Login now