Email Verification in afterCreate() event
Hello,
I have an application with two panels: admin and employee
Admin creates employee accounts and sends the email for verification
i use the code below in afterCreate() event
the email is sent correctly but Employee not have permission to access admin Panel and can't confirm the mail
How can I solve the problem?
29 Replies
What is the url generated?
/admin for admin panel
/employee for employee panel
So you need to call the panel which you are verifying against and not the current panel
http://xxx.server:8080/admin/email-verification/verify/21/efbee9998761bf518e8a0c66b055209c8e90051d?expires=1719327455&signature=b3d3659ed3c5dec68a8ce664da59ab36196cfd3bc99231d2be0747c8215d9f12
Exactly, but I don't know how
instead of /admin it would be /employee
Filament::getPanel('employee')->getVerifyEmailUrl($user);
http://xxx.server:8080/employee/email-verification/verify/22/efbee9998761bf518e8a0c66b055209c8e90051d?expires=1719327695&signature=a6bb7b4a3d21682e7482f063d30f243518eebfb0ecef461bd43a3710688699f3
the url is ok but the result is forbidden
in User model i have set this:
does it work if you
return true
in this method?yes
need to create Custom EmailNotification?
Try to authenticate in the employee panel with this account created before clicking the email verification link. I think this link should work if you are logged into the panel because when you create an account via the registration form, a session is created, and you are redirected to the panel without permissions to see the menu, etc, only the logout button.
No man not work because in canAccessPanel() i set $this->hasVerifiedEmail()
I think they need to access the panel to validate the account
GitHub
Resetting Password for Admin-Created User Accounts via Email. · fil...
How can an admin send a password reset link to a user after creating their account via mail? protected function afterCreate(): void { Password::sendResetLink(['email' => $this->record...
thnks go to test 🙂
worked?
hello, switch to this solution
FilamentApps
Filament: Invite Only Registration via Email Invitations
Learn how to implement an invite-only registration feature using Filament, ensuring exclusive access to your platform and enhancing user engagement through personalized invitations and controlled membership enrollment.
in class UserInvitationMail extends Mailable
in function
public function content(): Content
{
return new Content(
markdown: 'mail.auth.invitation',
with: [
'acceptUrl' => URL::signedRoute(
'filament.app.register',
[
'token' => $this->invitation->code,
],
),
],
);
}
got error in Route [filament.app.register] not defined.
@Leandro Ferreira how to fix?
hum, custom registration
you should check if this route exists
Doesn't this seem like a good solution?
not sure, I don't know this content.. but you can try
Ok its work at 99%
There's only one thing that doesn't work...
in class CustomRegister extends BaseRegister
in function register()
user after account creation go to /admin panel with forbidden error (because is it default???)
instead of /employee panel
Is there a way to point to the correct panel? return a redirect url?
maybe setting the current panel?
99,9% :squint:
Route [login] not defined.
go /employee
instead of employee/login
if refresh page go to login correctly
ok its works
add this in web.php
Route::get('/login', function () {
return redirect(route('filament.employee.auth.login'));
})->name('login');
Isn't that route automatically created when chaining the
login()
method to the panel?it should..but custom register use /login route and not panelid/login route
try to add in the web.php
ahh, I didn't notice.. this is the same as you did
test your code and works
Leandro, this it works. Thanks. Additional help:
1) How do you translate the password reset form into another language?
2) After resetting the password, how do you pass the email into the input of the login page (when coming from the password reset form)?