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:
parent
719ce073c3
commit
61b94b5176
3 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue