From 490c82f9f95aa793772a823fba4c333e31f8bae5 Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Wed, 23 Oct 2024 16:59:00 +0530 Subject: [PATCH] Refer to policy before checking user role --- src/Resources/TokenResource.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Resources/TokenResource.php b/src/Resources/TokenResource.php index 9c0c913..daff2d7 100644 --- a/src/Resources/TokenResource.php +++ b/src/Resources/TokenResource.php @@ -42,6 +42,10 @@ public static function form(Form $form): Form ->hidden(function () { $user = auth()->user(); + $policy = config('api-service.models.token.enable_policy', true); + + if ($policy === false) return false; + return ! $user->hasRole('super_admin'); }) ->required(),