user registration->email verification?
Hey guys!
Very simple expectations:
User registers, gets an email, verifies email, access to panel granted.
Until email is verified, can see a simple page that requires email verification and logout button.
I added:
->login()
->registration()
->passwordReset()
->emailVerification()
Also, in user:
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
public function canAccessPanel(Panel $panel): bool
{
return $this->hasVerifiedEmail();
}
Once I register, I a get 403, also, I get an email from laravel, but can't verify, when link clicked, I also get 403 π
https://my.domain.com/app/email-verification/verify/6/9cfe7a9376fb486b8ca0f44e7a1Ks9d90edbab?expires=1717465822&signature=cf90b6332309279d89ab36586c81e1161d9c0b5700598cfca6e0765f2e065430
Is there any good paper/document/tutotial on how to implement this? I checked website/s, this discord, reddit, chatgpt, claude π
Thanks!
10 Replies
After some thinking, I replaced return $this->hasVerifiedEmail(); in user model to
return true;
And now it does great
@RuZZZZ returning
true
from hasVerifiedEmail()
means that you've essentially disabled email verification. That method should check whether the user has verified their email.
If it always returns true, the user never needs to verify their email.As Tetracyclic says.... so if you want to disable it, remove the middleware instead to avoid the extra classes that you are not using.
I believe the email verification route is protected by Filament's authentication middleware, which in turn uses
canAccessPanel()
, so by requiring a verified email in canAccessPanel
, it's getting stuck in a loop where it won't let you access the email verification route, because the email isn't verified yet.
https://github.com/filamentphp/filament/blob/cecc1450bb52374a39f720c87262f65b9fc9a2a0/packages/panels/routes/web.php#L71
Instead of overwriting hasVerifiedEmail()
, you could instead check in canAcessPanel
whether the user is trying to access the email verification route, and if so return true
, otherwise check hasVerifiedEmail()
Something like:
(not tested this)wow, someone actually read my dummy question π
Thanks
>I believe the email verification route is protected by Filament's authentication middleware, which in turn uses canAccessPanel(), so by requiring a verified email in canAccessPanel, it's getting stuck in a loop where it won't let you access the email verification route, because the email isn't verified yet.
I think this is precisely what happened.
I guess this will only partially help, because there is not just email verification route, but this one too
You could do
str_starts_with(Route::currentRouteName(), 'auth.email-verification.')
The two routes are auth.email-verification.verify
and auth.email-verification.prompt
, so you could also check them individuallyty
Hi,I want to ask how to get the email message from laravel .Did the exact step like you but did not get the email message
php artisan queue:work ?