[英]how redirect user after email verification in laravel 8 and nuxtjs
在 laravel 8 和 nuxtjs 验证 email 后如何重定向用户?
email验证码
public function verify(Request $request)
{
auth()->loginUsingId($request->route('id'));
if ($request->route('id') != $request->user()->getKey()) {
throw new AuthorizationException;
}
if ($request->user()->hasVerifiedEmail()) {
return response(['message'=>'Already verified']);
// return redirect($this->redirectPath());
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return response(['message'=>'verified']);
}
如何将用户重定向到 localhost:3000?
在您的通知文件中这样做(例如 Notifications/VerifyEmailNotification.php):
public function toMail($notifiable)
{
$spa_url = env('SPA_URL') . '/email/verify/';
$id = $notifiable->getKey();
$hash = sha1($notifiable->getEmailForVerification());
$spa_url .= "{$id}/{$hash}";
$url = UrlSigner::sign($spa_url, Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)));
return (new MailMessage)
->line('Please click the button below to verify your email address.')
->action('Verify Email Address', url($url))
->line('This link expires in 1 hour and can only be used once. You can always request another link to be sent if this one has been used or is expired.');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.