In the VerifyEmailController, add the following before the existing code;
if (! $request->hasValidSignature()) {
return redirect()->route('invalidSignature');
}
This moves the signature checking from the middleware into the controller so that we can take control of the response. Here we redirect the user to a new view of our own design.
Duplicate the file resources/views/auth/verify-email.blade into verify-invalid.blade.php
Change it as below (only the message in the first div changes);
<x-guest-layout>
<div class="mb-4 text-sm text-gray-600">
{{ __('Sorry but that verification link is no longer valid, click below to request a new one.') }}
</div>
@if (session('status') == 'verification-link-sent')
<div class="mb-4 text-sm font-medium text-green-600">
{{ __('A new verification link has been sent to the email address you provided during registration.') }}
</div>
@endif
<div class="flex items-center justify-between mt-4">
<form method="POST" action="{{ route('verification.send') }}">
@csrf
<div>
<x-primary-button>
{{ __('Resend Verification Email') }}
</x-primary-button>
</div>
</form>
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="text-sm text-gray-600 underline rounded-md hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
{{ __('Log Out') }}
</button>
</form>
</div>
</x-guest-layout>
The main difference to the above process is that the view to copy is located in resources/views/livewire/pages/auth/verify-email.blade.php
Remember that the default behaviour is that the user must be logged in when checking the verification email since the routes are wrapped in auth middleware