Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r838:f3c1c942cc51 - - 2 files changed: 5 inserted, 3 deleted
@@ -34,8 +34,7 | |||||
|
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 |
@@ -1,6 +1,9 | |||||
|
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 |
You need to be logged in to leave comments.
Login now