0

i have a Laravel 5.4 application where i do all Authentication based logic through PHP and then redirect the user to a catchAll route when they are authenticated, and let VueRouter take it from there...

I'd like to also use Entrust because my app will have several types of users and some elements (like an Edit User button) will only be visible to some user Roles. I might also want to implement specific permissions, like some Admins can edit user Permissions, while others do not.

The issue is, alright i'm in Javascript territory now, so how do i know what my current Auth user is? Setting a global JS variable for Auth::user doesn't seem like a good idea to me.

Perhaps i would instead pass just an ID, but how exactly without making it globally visible as a window variable?

1 Answer 1

2

I think you may create an auth/check API call, like this:

protected function check()
{
    if(Auth::guard('api')->check()) {
        return Auth::guard('api')->user();
    }

    return ['success' => false];;
}

And then get current user with this call.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes @PetrReshetin i guess that will have to do, there's no wrapper for that kind of stuff yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.