forum posts: raise privilege error when viewing restricted topics.
Raise a privilege error when trying to view a restricted topic instead of handling it in the controller. This way error handling is standardized.
This commit is contained in:
@@ -76,24 +76,7 @@ private
|
||||
end
|
||||
|
||||
def check_min_level
|
||||
if CurrentUser.user.level < @forum_topic.min_level
|
||||
respond_with(@forum_topic) do |fmt|
|
||||
fmt.html do
|
||||
flash[:notice] = "Access denied"
|
||||
redirect_to forum_topics_path
|
||||
end
|
||||
|
||||
fmt.json do
|
||||
render json: nil, :status => 403
|
||||
end
|
||||
|
||||
fmt.xml do
|
||||
render xml: nil, :status => 403
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
raise User::PrivilegeError if CurrentUser.user.level < @forum_topic.min_level
|
||||
end
|
||||
|
||||
def check_privilege(forum_post)
|
||||
|
||||
Reference in New Issue
Block a user