Skip to content

Commit

Permalink
Changed order of check
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDJ committed Jul 26, 2023
1 parent 2355c86 commit 99a90ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Middlewares/PermissionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function handle($request, Closure $next, $permission, $guard = null)
$user = $authGuard->user();

// For machine-to-machine Passport clients
if (config('permission.use_passport_client_credentials') && ! $user && $request->bearerToken()) {
if (! $user && $request->bearerToken() && config('permission.use_passport_client_credentials')) {
$user = Guard::getPassportClient($guard);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Middlewares/RoleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function handle($request, Closure $next, $role, $guard = null)
$user = $authGuard->user();

// For machine-to-machine Passport clients
if (config('permission.use_passport_client_credentials') && ! $user && $request->bearerToken()) {
if (! $user && $request->bearerToken() && config('permission.use_passport_client_credentials')) {
$user = Guard::getPassportClient($guard);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Middlewares/RoleOrPermissionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function handle($request, Closure $next, $roleOrPermission, $guard = null
$user = $authGuard->user();

// For machine-to-machine Passport clients
if (config('permission.use_passport_client_credentials') && ! $user && $request->bearerToken()) {
if (! $user && $request->bearerToken() && config('permission.use_passport_client_credentials')) {
$user = Guard::getPassportClient($guard);
}

Expand Down

0 comments on commit 99a90ec

Please sign in to comment.