Search code examples
phplaravelemail-verification

Laravel 6.x VerifiesEmails.php fails with $request->route('hash'), passes with $request->get('hash')


In \Illuminate\Foundation\Auth\VerifiesEmails.php, line 39 fails with $request->route('hash'), but passes with $request->get('hash'). I am not sure if this is a bug, but I see nothing I have done that would somehow break this function specifically right here. I have not modified my VerificationController.php file from the core either.

The $request->route('id') above works, but the passed ID in this route is not a parameter, but directly in the path whereas the hash is affixed as ?hash=myhash.

For reference, here is my URL: http://localhost:8000/email/verify/8edd16a5-ad04-4782-b0fe-33f0f482d080?expires=myexpiryhere&hash=myhashhere&signature=mysignaturehere

Can anyone explain to me how to get this working? Obviously modifying the vendor files is not an option. I posted this in the Laravel issues here, but was directed out with the suggestion that maybe I forgot a route parameter. The URL is generated by the framework, so I've no idea what parameter I could be forgetting.


Solution

  • This is my bad, but thanks to Chin Leung for asking the right question.

    My current routes are:

    Route::get('email/verify', [VerificationController::class, 'show'])->name('verification.notice');
    Route::get('email/verify/{id}', [VerificationController::class, 'verify'])->name('verification.verify');
    Route::post('email/resend', [VerificationController::class, 'resend'])->name('verification.resend');
    

    I specify them myself because I do not use the default namespacing in my routes files, I import the controllers directly to make refactoring easier. It looks like a new param was added to the verification.verify route later on, so it should now be email/verify/{id}/{hash}