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