I can send emails for authentication in my Laravel application but when I click the verify button from the email I get redirected to a page with error 403.
I found this solution here: Missing required parameters for [Route: verification.verify] [URI: {locale}/email/verify/{id}/{hash}] because I had another problem. So in my web.php
for verification I have these lines of code:
Route::get('email/verify', '\App\Http\Controllers\Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', '\App\Http\Controllers\Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', '\App\Http\Controllers\Auth\VerificationController@resend')->name('verification.resend');
and the link for verification looks like this:
<a href="{{ route('verification.verify', ['id' => $user->id, 'hash' => $user->verification_token]) }}">Verify Email</a>
The verify() function in my VerificationController looks like this:
public function verify(Request $request, $id, $hash)
{
$user = User::findOrFail($id);
if ($user->email_verified_at) {
return redirect()->route('home')->with('warning', 'Your email has already been verified.');
}
if (!hash_equals((string) $hash, sha1($user->getEmailForVerification()))) {
return redirect()->route('home')->with('error', 'Invalid verification link.');
}
$user->markEmailAsVerified();
return redirect()->route('home')->with('success', 'Your email has been verified!');
}
I will provide additional info if needed as soon as possible