synapse policy
This commit is contained in:
parent
52facb9c1d
commit
baca4aac83
1 changed files with 25 additions and 0 deletions
25
app/policies/synapse_policy.rb
Normal file
25
app/policies/synapse_policy.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
class SynapsePolicy < ApplicationPolicy
|
||||||
|
class Scope < Scope
|
||||||
|
def resolve
|
||||||
|
scope.where('permission IN ("public", "commons") OR user_id = ?', user.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create?
|
||||||
|
user.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def show?
|
||||||
|
#record.permission == 'commons' || record.permission == 'public' || record.user == user
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def update?
|
||||||
|
#user.present? && (record.permission == 'commons' || record.user == user)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy?
|
||||||
|
record.user == user || user.admin
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue