File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,19 @@ class AuthRoles
20
20
*/
21
21
public function handle ($ request , Closure $ next )
22
22
{
23
-
24
- $ guard = auth ('api ' )->check () ? 'api ' : '' ;
25
23
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 ());
27
31
28
32
$ action = $ request ->route ()->getActionname ();
29
33
$ name = $ request ->route ()->getActionname ();
30
34
31
- $ role_id = auth ($ guard )->user ()->role_id ;
35
+ $ role_id = auth ($ authGuard )->user ()->role_id ;
32
36
33
37
$ permission = Permission::where (function ($ query )use ($ action , $ name ){
34
38
$ query ->where ('name ' , $ name );
You can’t perform that action at this time.
0 commit comments