Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording User ID does not work with custom guards #75

Open
bobwurtz opened this issue Mar 12, 2020 · 0 comments
Open

Recording User ID does not work with custom guards #75

bobwurtz opened this issue Mar 12, 2020 · 0 comments

Comments

@bobwurtz
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant