用户Oj界面权限问题

dev_daiao
daiao 5 years ago
parent f0e7dd7b09
commit 0ca6108f08

@ -41,4 +41,9 @@ class Hack < ApplicationRecord
hack_sets.first&.input
end
# 管理员
def manager?
user_id == current_user.id || current_user.admin_or_business?
end
end

@ -15,3 +15,7 @@ end
json.user do
json.partial! 'users/user', user: current_user
end
json.user_auth do
json.manager @hack.manager?
end

@ -1,5 +1,5 @@
# 编程内容
json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not)
json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not, :status)
# 代码
json.language @hack.language

Loading…
Cancel
Save