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

Multi Guard issue. #15

Closed
Saifallak opened this issue Apr 30, 2022 · 4 comments · Fixed by #22
Closed

Multi Guard issue. #15

Saifallak opened this issue Apr 30, 2022 · 4 comments · Fixed by #22

Comments

@Saifallak
Copy link
Contributor

using this package with two guards "web" (those my website users) and "admins" (filament users)
and added this package to both.
the problem is when impersonating "web", it works well.
but when trying to impersonate "admins" guard, it just picks the same id in guard "web"

lost? me too 😂.

so in admins table

  • id (1) admin1
  • id (2) admin2

and in users table

  • id (1) user1
  • id (2) user2

when i click impersonate on admin2, it impersonate user2 instead.

auth.php

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'clients',
        ],

        'admins' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
    ],
@Saifallak
Copy link
Contributor Author

i guess it's easy to do. just need to pass guard name too in the method
as stated here (last block of code before advanced usage)
https://github.com/404labfr/laravel-impersonate#using-the-built-in-controller

@jszobody
Copy link
Member

jszobody commented May 1, 2022

There is already support for specifying a different guard when impersonating:

https://github.com/stechstudio/filament-impersonate/blob/master/config/filament-impersonate.php#L4

https://github.com/stechstudio/filament-impersonate/blob/master/src/Impersonate.php#L38-L40

Is this what you're looking for?

@Saifallak
Copy link
Contributor Author

Nearly,..
I need to use multi guards in the same project..

So ineed to specify the guard to impersonate each time

So when impersonating admins use guard admins and when impersonating users use guard web..

I don't want to rely on one guard in config ( i don't mind if in config we can set default guard ) and i don't want to rely on filment guard too ..

@Saifallak
Copy link
Contributor Author

So there is two approaches..

  • add method to Model (ex: app/Models/Admin.php) called getAuthGuard() and we can use it ..

  • add parameter to impersonate function to accept guard ( if not passed use one from config ) ..

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

Successfully merging a pull request may close this issue.

2 participants