F
Filamentβ€’3w ago
deveti

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
Dennis Koch
Dennis Kochβ€’3w ago
Did you use ->emailVerification()?
deveti
devetiOPβ€’3w ago
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
Dennis Koch
Dennis Kochβ€’3w ago
I don't think you need $this->hasVerifiedEmail(); when using ->emailVerification(). That's causing the 403
deveti
devetiOPβ€’3w ago
yeah but if I just return true, then anyone can login? oh my god, it works
Dennis Koch
Dennis Kochβ€’3w ago
Did you try it?
deveti
devetiOPβ€’3w ago
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 πŸ˜„
deveti
devetiOPβ€’3w ago
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!

Did you find this page helpful?