File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 28
28
'morph_prefix ' => 'user ' ,
29
29
'guards ' => [
30
30
'web ' ,
31
- 'api ' ,
31
+ 'api '
32
32
],
33
- 'resolver ' => OwenIt \Auditing \Resolvers \UserResolver::class
33
+ 'resolver ' => OwenIt \Auditing \Resolvers \UserResolver::class
34
34
],
35
35
36
36
/*
Original file line number Diff line number Diff line change 2
2
3
3
namespace OwenIt \Auditing \Contracts ;
4
4
5
+ use Illuminate \Auth \Authenticatable ;
6
+
5
7
interface UserResolver
6
8
{
7
9
/**
8
10
* Resolve the User.
9
11
*
10
- * @return mixed |null
12
+ * @return Authenticatable |null
11
13
*/
12
14
public static function resolve ();
13
15
}
Original file line number Diff line number Diff line change 7
7
8
8
class UserResolver implements \OwenIt \Auditing \Contracts \UserResolver
9
9
{
10
+ /**
11
+ * @return \Illuminate\Contracts\Auth\Authenticatable|null
12
+ */
10
13
public static function resolve ()
11
14
{
12
15
$ guards = Config::get ('audit.user.guards ' , [
13
- 'web ' ,
14
- 'api ' ,
16
+ \config ('auth.defaults.guard ' )
15
17
]);
16
18
17
19
foreach ($ guards as $ guard ) {
18
- if (Auth::guard ($ guard )->check ()) {
20
+ try {
21
+ $ authenticated = Auth::guard ($ guard );
22
+ } catch (\Exception $ exception ) {
23
+ continue ;
24
+ }
25
+
26
+ if ($ authenticated ) {
19
27
return Auth::guard ($ guard )->user ();
20
28
}
21
29
}
30
+
31
+ return null ;
22
32
}
23
33
}
You can’t perform that action at this time.
0 commit comments