Skip to content

Commit 94a12a5

Browse files
pahan35barryvdh
authored andcommitted
Fix exception on fetching Auth api user info (barryvdh#889)
* Fix exception on fetching Auth api user info I noticed such exception in my log during debugging API queries ``` [2018-11-23 01:25:43] local.ERROR: Debugbar exception: Method Illuminate\Database\Query\Builder::getAuthIdentifier does not exist. ``` So I've found a problem and fixed it * Add missed use
1 parent 6a42db2 commit 94a12a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/DataCollector/MultiAuthCollector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DebugBar\DataCollector\DataCollector;
66
use DebugBar\DataCollector\Renderable;
77
use Illuminate\Auth\SessionGuard;
8+
use Illuminate\Contracts\Auth\Authenticatable;
89
use Illuminate\Contracts\Auth\Guard;
910
use Illuminate\Support\Str;
1011
use Illuminate\Contracts\Support\Arrayable;
@@ -111,7 +112,7 @@ protected function getUserInformation($user = null)
111112

112113
// The default auth identifer is the ID number, which isn't all that
113114
// useful. Try username and email.
114-
$identifier = $user->getAuthIdentifier();
115+
$identifier = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->id;
115116
if (is_numeric($identifier)) {
116117
try {
117118
if ($user->username) {

0 commit comments

Comments
 (0)