I have a Laravel application that acts as a backend API for the VueJS frontend. I have overwritten the handle method of the EnsureEmailIsVerified middle in order to have the frontend handle redirection.
The problem I am facing has to do with the /mail/send-verification route which is behind the auth middleware to get the user. The registration process returns access and refresh tokens for the frontend to be able to call /mail/send-verification. In the case where the user registers and tries to login before verifying their email, the backend returns a 403 "Your email address is not verified." which prevents the frontend from being able to call send-verification since it doesn't have a the access token.
Route::post('/email/send-verification', [VerificationController::class, 'send'])->middleware('auth:api');
What approach should I take to resolve this? Is there a better way to implement the registration email verification process?
First you need to create a custom notification. Second you need controller for requesting verification and confirmation code. Thired a model and table row for saving vcodes
In my case custom email verification trough api requests done like this: path: app/Notifications/apiEmailVerification.php
now email verification controller to send verification code by mail to user's email: for example EmailVerificationController.php
and EmailConfirmationController.php
a model for email verification is necessary:
This is just an example. You probably need to add some functions for displaying forms, hashing codes or etc related to your website situation and needs.