php - 重新发送电子邮件的功能将我带到主页,并且在给定功能中什么都不做 - Laravel

标签 php laravel authentication

我有这个简单的功能,可以点击发送电子邮件给用户,如果注册后的第一个邮件没有成功的话。但是当我点击按钮时,它没有任何反应,而是将我带到主页。

重发功能:

protected function resend()
    {
        $user = Account::where('email', Auth::user()->email)->first();
        $user->verifyToken = Str::random(40);
        $user->save();

        $this->sendEmail($user);
        return redirect(route('verifyEmail'))->with('user',$user)->with('success', 'A link has been sent to your email');

    }

Route::post('/resend/email', 'Auth\RegisterController@resend')->name('resendEmail');

html:

<form action=" {!! route('resendEmail') !!}" method="POST">
   @csrf
      <button class="btn btn-default" type="submit" value="Submit">Resend Verification Link</button>
</form>

通过添加到构造函数解决的中间件问题: $this->middleware('auth', ['except' => ['resendEmail']]);

最佳答案

RegisterController __construct 方法上添加:

$this->middleware('auth', ['except' => ['account/security/resend/email']]);

关于php - 重新发送电子邮件的功能将我带到主页,并且在给定功能中什么都不做 - Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62918111/

相关文章:

php - 从句子中随机隐藏单词

php - 从文本到数组的坐标 [preg_match]

php - Laravel 验证多列的唯一规则

wordpress - 如何在 WordPress 中通过 URL 注销?

asp.net-mvc-3 - 授权属性 MVC 3 和 Web.Config AppSettings 值

ASP.Net 身份验证和 Googlebot

php - 在页面上显示数据库中的照片时出现问题

php - 自定义 wordpress 主题 : layout images not displaying

php - 使用 Laravel 对重复电子邮件进行 Jquery 验证

php - 如何使用 Laravel 进行左外连接?