Skip to content

Commit

Permalink
Refactor user vs actor in user policy
Browse files Browse the repository at this point in the history
  • Loading branch information
stage-rl committed Dec 4, 2023
1 parent 186746e commit 2fc4777
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/policies/admin/user_policy.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# frozen_string_literal: true

class Admin::UserPolicy < ApplicationPolicy
attr_reader :user

def initialize(actor, user_to_authorize)
@actor = actor
@user_to_authorize = user_to_authorize
end

def user
@actor
end

class Scope < Scope
def initialize(actor, scope)
@actor = actor
@scope = scope
end

def user
@actor
end

def resolve
if @actor.site_admin?
scope.all
Expand Down

0 comments on commit 2fc4777

Please sign in to comment.