Recording User ID does not work with custom guards
bobwurtz opened this issue · 0 comments
bobwurtz commented
Tyler - this is a great service. Thanks for putting it together.
One issue I had was recording an exception for a user with a custom guard. The value for user_id was null. A workaround I came up with is to edit the getUserId function within the Components/Recorder.php file:
`protected function getUserId() {
$user = Auth::user();
if (!isset($user)) {
$user = Auth::guard('manager')->user();
} if (!isset($user)) {
$user = Auth::guard('admin')->user();
}
if (is_object($user) && !empty($user->id)) {
return $user->id;
} else {
return null;
}
}`
Thought I would post for anyone who comes across this problem later on.
Maybe a future release could include an array in the config/lern.php where the user could enter a list of guards to check for a logged in user?
Thanks again