F
Filament14mo ago
DrByte

Password-less login via email link ... in v3

I've seen a couple v2 plugins for password-less login via a signed magic-link sent via email. Looking for one that works with v3 ... because I've not yet been able to convert either of those to make it work. ie: I've tried https://github.com/ArtMin96/filament-password-less and https://github.com/bradyrenting/filament-passwordless
GitHub
GitHub - ArtMin96/filament-password-less: Password-less login for F...
Password-less login for Filament. Contribute to ArtMin96/filament-password-less development by creating an account on GitHub.
GitHub
GitHub - bradyrenting/filament-passwordless: Passwordless authentic...
Passwordless authentication for Filament. Contribute to bradyrenting/filament-passwordless development by creating an account on GitHub.
13 Replies
stanwarri
stanwarri12mo ago
Were you able to get this working @DrByte ?
DrByte
DrByteOP12mo ago
I built my own directly into my v3 app, taking a bunch of inspiration from bradyrenting's v2 package and exploring/extending the v3 core code
stanwarri
stanwarri12mo ago
I'm currently doing the same but running into an issue when I'm redirected back to the login page after clicking on the sent link. Will you be able to share with me some of your processes?
toeknee
toeknee12mo ago
Then that URL must be handled by the middleware, you just need a controller which will handle the link that comes back
stanwarri
stanwarri12mo ago
I already have the controller that handles the link.
public function __invoke(string $key, bool $remember = false): LoginResponse
{
$user = app(Passwordless::class)->getUserById($key);

Filament::login($user, true);

session()->regenerate();

return app(LoginResponse::class);
}
public function __invoke(string $key, bool $remember = false): LoginResponse
{
$user = app(Passwordless::class)->getUserById($key);

Filament::login($user, true);

session()->regenerate();

return app(LoginResponse::class);
}
Instead of redirecting to the dashboard from here, it takes me back to the login page
toeknee
toeknee12mo ago
do a dump(Filament::login($user, true)) and also the session regen to see what you get. If it logged them in then it would be fine.. I also don't see a Filament::login exisitng I think you want:
Filament::auth()->login($user, true);
Filament::auth()->login($user, true);
stanwarri
stanwarri12mo ago
I actually did this dd(Filament::auth()->login($user, true)). Also it returns null Also dd(session()->regenerate()) returns true
toeknee
toeknee12mo ago
And what is $user return on DD
awcodes
awcodes12mo ago
I’m thinking the same thing. The Passwordless class is not finding the user. $key may not be the value you expect or may need decoding
toeknee
toeknee12mo ago
Exactly my thoughts 🙂 If the login is null there's a reason and I've got a feeling there is no user.
DrByte
DrByteOP12mo ago
@stanwarri I've extracted the files that handle it into a repo. See: https://github.com/drbyte/filament3-passwordless-email-login-demo/ I "hope" I've captured all of it. And please note that I basically copied code from my production app into a blank repo, so that it's easy to see what files are involved and where they "go". Hopefully it's enough to bolt the feature onto your own site.
I also put a bunch of detail into the Readme to help it make sense.
GitHub
GitHub - drbyte/filament3-passwordless-email-login-demo: Demo for i...
Demo for implementing passwordless login via email using Filament 3.1 - GitHub - drbyte/filament3-passwordless-email-login-demo: Demo for implementing passwordless login via email using Filament 3.1
stanwarri
stanwarri12mo ago
It is actually returning an instance of the User Model.
No description
stanwarri
stanwarri12mo ago
Thanks for sending this. I will give it a try and let you know how it goes. It is similar to my existing implimentation already, but I might be missing one or two things Still didn't work. For context, I'm implementing this on a subdomain. I'm beginning to think the issue has to do with session configuration
Want results from more Discord servers?
Add your server