Renaming method to reduce surprise (#15632)

Given that we have the roles of `:tech_admin`, `:admin`, and
`:super_admin`, I don't want the surprise of assuming that `user.admin?`
means that they have the role of `:admin`.
This commit is contained in:
Jeremy Friesen 2021-12-01 16:38:26 -05:00 committed by GitHub
parent 719ce073c3
commit 61b94b5176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -55,7 +55,7 @@ class NotificationsController < ApplicationController
private
def user_to_view
if params[:username] && current_user.admin?
if params[:username] && current_user.super_admin?
User.find_by(username: params[:username])
else
current_user
@ -83,6 +83,6 @@ class NotificationsController < ApplicationController
end
def allowed_user?
@user.org_member?(params[:org_id]) || @user.admin?
@user.org_member?(params[:org_id]) || @user.super_admin?
end
end

View file

@ -356,7 +356,7 @@ class User < ApplicationRecord
# Included as a courtesy but let's consider removing it.
alias warned warned?
def admin?
def super_admin?
has_role?(:super_admin)
end

View file

@ -30,7 +30,7 @@ Doorkeeper.configure do
# Example implementation:
if current_user
head :forbidden unless current_user.admin?
head :forbidden unless current_user.super_admin?
else
warden.authenticate!(scope: :user)
end