How to make Signed route invalid after use means how to make link which use only once
current code is like below
URL::signedRoute('email.verify', ['id' => $user->id], now()->addMinutes(30))
How to make Signed route invalid after use means how to make link which use only once
current code is like below
URL::signedRoute('email.verify', ['id' => $user->id], now()->addMinutes(30))
If you look at how the framework does this for the temporary signed route for the initial user verification email. You should see it can be quite easy for your case too.
Framework:
/**
* Get the verification URL for the given notifiable.
*
* @param mixed $notifiable
* @return string
*/
protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
]
);
}
Yours:
URL::temporarySignedRoute(
'email.verify',
now()->addMinutes(30),
['id' => $user->id],
);
You can use the below logic as per your requirement.
Generate a temporary signed route URL that expires, you may use the temporarySignedRoute method
To verify that an incoming request has a valid signature, you should call the hasValidSignature method on the incoming Request.