passport-multiauth icon indicating copy to clipboard operation
passport-multiauth copied to clipboard

How to check the authenticated user types

Open digihiveinc opened this issue 6 years ago • 5 comments

We built a system where we have admin and client user types. Admin can "operate as" a client. In real terms, admin can log in on behalf of a client and navigate client resources. The key is, when admin is logged in "as client" (thus both user types are logged in) we should be able to identify such instance.

Is it possible to check if a certain type of guard authorized/logged on given resources? Before passport-multiauth we were using Auth::guard($guard)->check() to identify if a certain user type is authorized.

Please help.

digihiveinc avatar Mar 07 '19 05:03 digihiveinc

@digihiveinc please check if it solve your problem https://github.com/sfelix-martins/passport-multiauth/issues/63#issuecomment-458506088 to use Auth::guard($guard)->check().

sfelix-martins avatar Mar 07 '19 11:03 sfelix-martins

@sfelix-martins thank you for the quick response.

no, that doesn't fix the issue we have.

We have different types of user: admin, client, etc. How do we check in the client area, if the admin is logged in as well?

digihiveinc avatar Mar 07 '19 19:03 digihiveinc

I think that you can get the logged user from $request->user() or Auth::user() and check is an instance of your model.

sfelix-martins avatar Mar 07 '19 19:03 sfelix-martins

This only gets the info about the current instance and user. I am trying to find a way how to check if completely different type of user is logged in the system.

Imagine this scenario: user1 is logged in as ADMIN in admin area user2 is logged in as CLIENT in client area

ADMIN can navigate within client area and client area must be aware that ADMIN is navigating it.

Hope this is not to abstract...

digihiveinc avatar Mar 07 '19 20:03 digihiveinc

@digihiveinc Did you get a solution to the problem?

SachinBahukhandi avatar Mar 22 '19 11:03 SachinBahukhandi