using Laravel 7.19
all my routes require a locale , including my Auth Routes to support different languages. And I've activated email verficitation for the users.
So once a user , that didn't verfiy his email , tries to open a part of my website that requires email verficitation Laravel automatically redirects them to this route : verification.notice
The Problem is that the route requires the locale parameter but I don't know how to pass the locale to the route. So I'm getting this error message
Missing required parameters for [Route: verification.notice] [URI: {locale}/email/verify].
Anyone knows the function that redirects me to the route : verification.notice ? Because I need to adjust or overwrite it so I can pass the locale parameter to it.
My web.php
Route::group(['middleware' => ['setlocale'],'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}']], function() {
Auth::routes(['verify' => true]);
});
EDIT : Found Something usefule . Inside the File /vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php
There's a function handle
If I add app()->getLocale() to it , the error message is gone. Looking like this now
public function handle($request, Closure $next, $redirectToRoute = null)
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route($redirectToRoute ?: 'verification.notice',app()->getLocale());
}
return $next($request);
}
But I don't don't think you're supposed to make changes to /vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php
How do I correctly overwrite this function ?