c6digital / filament-passwordless-login

MIT License
5 stars 1 forks source link

Authentication other than User Model #10

Open arshaviras opened 2 weeks ago

arshaviras commented 2 weeks ago

What happened?

I have two panels one is Admin and second is Student. I have Student Model which extends Authenticatable and implements FilamentUser. I want to generate passwordless links and send to students and they can login via magic link. In plugin I changed all User models to Student model. Also changed in file PasswordlessLogin.php return URL::temporarySignedRoute('filament.' . Filament::getCurrentPanel()->getId() . '.auth.link', now()->addMinutes(30), $user); to return URL::temporarySignedRoute('filament.' . 'student' . '.auth.link', now()->addMinutes(30), $user); because Filament::getCurrentPanel()->getId() return 'admin', because I generating links from Admin Panel for Student Panel. Added Action on Table and generated login link for student user.

How to reproduce the bug

When I trying to login via that generated link it redirect to login page. In addition I can login with email and password via plugin's custom login page.

What I need to change/add for success authenticating?

Package Version

0.3.0

PHP Version

8.2.12

Laravel Version

11.10.0

Which operating systems does with happen with?

Windows

Notes

No response

ryangjchandler commented 3 days ago

Hi @arshaviras – have you registered the plugin on both panels?

arshaviras commented 3 days ago

No, only on Student Panel

ryangjchandler commented 3 days ago

@arshaviras Okay, I think I see the problem. The registered routes use the guest middleware, but that defaults to checking against the default auth guard which I imagine is your regular User / admin panel.

Have you specified the custom auth guard on your panel too, using the authGuard() method?

arshaviras commented 3 days ago

Yes I have custom auth guard ->authGuard('web:students') So what I need to change/add and where?

Thanks

arshaviras commented 3 days ago

I think I need to change something there, but what I can't imagine public function register(Panel $panel): void { $panel ->login(Login::class) ->routes(function () { Route::get('/auth/{user}/link', LoginLinkController::class) ->middleware(['signed', 'guest']) ->name('auth.link'); }); }

ryangjchandler commented 3 days ago

We'll need to make a change to support this inside of the package. I'll update this issue once the release has been tagged.