我有这个用于注册用户的功能,这几乎是默认功能,但我添加了一个要发送到电子邮件的令牌,以便用户可以激活帐户,否则用户无法登录。所以我尝试添加一个重新发送功能,所以如果第一次未发送电子邮件时,他们可以手动重新发送,但这会导致 419 错误页面已过期。
注册功能
protected function create(array $data)
{
$user = Account::create([
'login' => $data['login'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'verifyToken'=> Str::random(40),
'active' => (env('CONFIRM_EMAIL', true)) ? 0 : 1
]);
$thisUser = Account::findOrFail($user->id);
$this->sendEmail($thisUser);
return $user;
}
这是重新发送的功能
protected function resend(Request $request)
{
$user = Account::where('email', $request->input('email'))->first();
$user->verifyToken = Str::random(40);
$user->save();
$this->sendEmail($user);
return $user;
}
我用这种形式称呼它
<form action=" {!! route('resendEmail') !!}" method="POST">
<fieldset class="youplay-input">
<input id="email" type="email" class="@error('email') is-invalid @enderror" placeholder="E-
mail" name="email" value="{{ old('email') }}" required autocomplete="email">
</fieldset>
<button class="btn btn-default db" type="submit" value="Submit">
Resend Verification Link
</button>
</form>
我已经和一个人讨论过这个问题,但我们找不到好的解决方案:How to make resend email link function in Laravel
九州编程