Skip to content

Commit

Permalink
feat!: let admin access all routes through policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Apr 15, 2022
1 parent a2e2639 commit 0e46ec4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/Ship/Parents/Policies/Policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@
namespace App\Ship\Parents\Policies;

use Apiato\Core\Abstracts\Policies\Policy as AbstractPolicy;
use App\Ship\Parents\Models\UserModel;

abstract class Policy extends AbstractPolicy
{
/**
* Perform pre-authorization checks.
*
* @param UserModel $user
* @param string $ability
* @return bool|null
*/
public function before(UserModel $user, string $ability): ?bool
{
//grant access for admins
if (method_exists($user, 'hasAdminRole') && $user->hasAdminRole()) {
return true;
}

return null;
}
}

0 comments on commit 0e46ec4

Please sign in to comment.