Admin panel register with verifyEmail
When user registers I would like to redirect it to verify email page - I can do that with RegistrationResponse. But if user manually enters the /admin part he gets 403 error.
Is there a way, to force redirect user to email verification page if his email is not verifed when he logs in?
Thanks!
8 Replies
Did you use
->emailVerification()
?Yes, I used it.
I have my own Registration class where I only change validation of email as I have a config value with allowed domains and I output the error there
I tried making a middleware, but I do not know exactly where to place it .. if I place it in the authMiddleware it does not get picked up (I get 403 before) and in the regulart middleware I get too many redirects
in my User model I have:
public function canAccessPanel(Panel $panel): bool
{
if (!$this->hasAllowedEmailDomain($this->email)) {
return false;
}
return $this->hasVerifiedEmail();
}
hasAllowedEmailDomain is my custom trait where I just check domain validity
I don't think you need
$this->hasVerifiedEmail();
when using ->emailVerification()
. That's causing the 403yeah but if I just return true, then anyone can login?
oh my god, it works
Did you try it?
well that should be in documentation
π
I do not want to admit how much time I spent now on this π
I tried everything except remove hasVerifiedEmail π
It's quickly mentioned but not thouroughly documented:
https://filamentphp.com/docs/3.x/panels/users#authentication-features
I know .. I know that page by heart now probably hehe
the only examples are with $this->hasVerifiedEmail()
but non the less, thank you very very much!