-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix admins being disallowed from tags pages
- Loading branch information
1 parent
6caa157
commit f72c5fe
Showing
3 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,25 +56,23 @@ def search | |
flash_search_warnings(@tags) | ||
end | ||
|
||
# if user is admin with view access or Tag Wrangler, show them details about the tag | ||
# if user is not logged in or a regular user, show them | ||
# 1. the works, if the tag had been wrangled and we can redirect them to works using it or its canonical merger | ||
# 2. the tag, the works and the bookmarks using it, if the tag is unwrangled (because we can't redirect them | ||
# to the works controller) | ||
def show | ||
authorize :wrangling, :read_access? if logged_in_as_admin? | ||
|
||
@page_subtitle = @tag.name | ||
if @tag.is_a?(Banned) && !logged_in_as_admin? | ||
if @tag.is_a?(Banned) | ||
if !logged_in_as_admin? | ||
flash[:error] = ts('Please log in as admin') | ||
redirect_to(tag_wranglings_path) && return | ||
elsif !policy(:wrangling).read_access? | ||
flash[:error] = ts('Sorry, only an authorized admin can access the page you were trying to reach.') | ||
Check warning on line 66 in app/controllers/tags_controller.rb GitHub Actions / Rubocop
Check warning on line 66 in app/controllers/tags_controller.rb GitHub Actions / Rubocop
Check warning on line 66 in app/controllers/tags_controller.rb GitHub Actions / Rubocop
|
||
redirect_to(root_path) && return | ||
end | ||
end | ||
# if tag is NOT wrangled, prepare to show works and bookmarks that are using it | ||
if !@tag.canonical && !@tag.merger | ||
if logged_in? # current_user.is_a?User | ||
Check warning on line 72 in app/controllers/tags_controller.rb GitHub Actions / Rubocop
|
||
@works = @tag.works.visible_to_registered_user.paginate(page: params[:page]) | ||
elsif logged_in_as_admin? | ||
@works = @tag.works.visible_to_owner.paginate(page: params[:page]) | ||
@works = @tag.works.visible_to_admin.paginate(page: params[:page]) | ||
else | ||
@works = @tag.works.visible_to_all.paginate(page: params[:page]) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters