【问题标题】:how redirect user after email verification in laravel 8 and nuxtjs在 laravel 8 和 nuxtjs 中的电子邮件验证后如何重定向用户
【发布时间】:2021-03-17 05:28:47
【问题描述】:

在 laravel 8 和 nuxtjs 中邮件验证后如何重定向用户??

电子邮件验证码

   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 ?

【问题讨论】:

  • 在发布答案或问题时,请注意代码格式和对齐方式。

标签: php laravel nuxt.js


【解决方案1】:

在您的通知文件中这样做(例如 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.');
        }

【讨论】:

    猜你喜欢
    • 2022-08-14
    • 2020-03-20
    • 2021-02-15
    • 2021-08-29
    • 2020-11-01
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多