File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,19 @@ class AuthRoles
2020 */
2121 public function handle ($ request , Closure $ next )
2222 {
23-
24- $ guard = auth ('api ' )->check () ? 'api ' : '' ;
2523
26- throw_if (!auth ($ guard )->check (), UnauthenticatedException::notLoggedIn ());
24+ $ guards = collect (config ('auth.guards ' ));
25+
26+ $ authGuard = $ guards ->keys ()->filter (function ($ key ) {
27+ return auth ($ key )->check ();
28+ })->first ();
29+
30+ throw_if (!auth ($ authGuard )->check (), UnauthenticatedException::notLoggedIn ());
2731
2832 $ action = $ request ->route ()->getActionname ();
2933 $ name = $ request ->route ()->getActionname ();
3034
31- $ role_id = auth ($ guard )->user ()->role_id ;
35+ $ role_id = auth ($ authGuard )->user ()->role_id ;
3236
3337 $ permission = Permission::where (function ($ query )use ($ action , $ name ){
3438 $ query ->where ('name ' , $ name );
You can’t perform that action at this time.
0 commit comments