Fix Policy conditions (#117)

This commit is contained in:
Chirag Chhatrala 2023-04-28 15:03:16 +05:30 committed by GitHub
parent 8cb368f455
commit 45fb114554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ class FormPolicy
*/ */
public function view(User $user, Form $form) public function view(User $user, Form $form)
{ {
return $user->workspaces()->find($form->workspace_id)->exists(); return $user->workspaces()->find($form->workspace_id) !== null;
} }
/** /**
@ -53,7 +53,7 @@ class FormPolicy
*/ */
public function update(User $user, Form $form) public function update(User $user, Form $form)
{ {
return $user->workspaces()->find($form->workspace_id)->exists(); return $user->workspaces()->find($form->workspace_id) !== null;
} }
/** /**
@ -65,7 +65,7 @@ class FormPolicy
*/ */
public function delete(User $user, Form $form) public function delete(User $user, Form $form)
{ {
return $user->workspaces()->find($form->workspace_id)->exists(); return $user->workspaces()->find($form->workspace_id) !== null;
} }
/** /**
@ -77,7 +77,7 @@ class FormPolicy
*/ */
public function restore(User $user, Form $form) public function restore(User $user, Form $form)
{ {
return $user->workspaces()->find($form->workspace_id)->exists(); return $user->workspaces()->find($form->workspace_id) !== null;
} }
/** /**
@ -89,6 +89,6 @@ class FormPolicy
*/ */
public function forceDelete(User $user, Form $form) public function forceDelete(User $user, Form $form)
{ {
return $user->workspaces()->find($form->workspace_id)->exists(); return $user->workspaces()->find($form->workspace_id) !== null;
} }
} }

View File

@ -20,11 +20,11 @@ class FormZapierWebhookPolicy
public function store(User $user, FormZapierWebhook $webhook) public function store(User $user, FormZapierWebhook $webhook)
{ {
return $this->formPolicy->update($user, $webhook->form); // && $user->is_subscribed; return ($webhook?->form) ? $this->formPolicy->update($user, $webhook->form) : false; // && $user->is_subscribed;
} }
public function delete(User $user, FormZapierWebhook $webhook) public function delete(User $user, FormZapierWebhook $webhook)
{ {
return $this->formPolicy->update($user, $webhook->form); // && $user->is_subscribed; return ($webhook?->form) ? $this->formPolicy->update($user, $webhook->form) : false; // && $user->is_subscribed;
} }
} }