重新发送电子邮件的功能将我带到主页,但在给定的功能中什么也不做-Laravel [英] Function for resend email takes me to the home page and does nothing in the given function - Laravel

查看:46
本文介绍了重新发送电子邮件的功能将我带到主页,但在给定的功能中什么也不做-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果注册后的第一封邮件没有发送,我具有单击此简单功能的功能,可以向用户发送电子邮件.但是,当我单击该按钮时,它什么也没做,而是带我到主页.

I have this simple function on click to send email to the users if the first one after registration didnt go. But when i click on the button it doesn nothing and takes me to the home page.

重新发送功能:

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')->名称('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']]);

这篇关于重新发送电子邮件的功能将我带到主页,但在给定的功能中什么也不做-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆