如果他们不是第一次收到邮件,我有这种方法试图让他们的电子邮件重新发送验证链接。问题是我不想让他们未经验证就登录,因为此数据库与游戏服务器连接,并且我不想让他们未经验证就登录。我试图存储电子邮件,所以“重新发送”按钮将其重新发送到该电子邮件,以发送验证链接,但是在我注册后以及尝试将我重定向到verify.blade时,我会收到。
未定义变量:用户
它指向隐藏的输入,我将在下面显示。
这是我的注册功能,可以正常运行并在数据库中注册用户:
protected function create(array $data)
{
$user = Account::create([
'login' => $data['login'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'verifyToken'=> Str::random(40),
'active' => (env('CONFIRM_EMAIL', true)) ? 0 : 1
]);
$thisUser = Account::findOrFail($user->id);
if(env('CONFIRM_EMAIL') == true){
$this->sendEmail($thisUser);
}
return $user;
}
此功能可以重定向或登录用户,具体取决于我是否将电子邮件验证设置为“ True”:
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
if(env('CONFIRM_EMAIL') == false){
$this->guard()->login($user);
}else{
return redirect(route('verifyEmail'));
}
if ($response = $this->registered($request, $user)) {
return $response;
}
return $request->wantsJson()
? new Response('', 201)
: redirect($this->redirectPath());
}
,这是带有隐藏输入的重发功能和html代码,将错误指向值=“ $ user-> email”:
protected function resend(Request $request)
{
$user = Account::where('email', $request->email)->first();
if($user){
$user->verifyToken = Str::random(40);
$user->save();
$this->sendEmail($user);
return back()->with('user',$user)->with('success', 'A link has been sent to your email');
}
}
<form action=" {!! route('resendEmail') !!}" method="POST">
@csrf
<input type="hidden" name="email" value="{{ $user->email }}">
<button class="btn btn-default db" type="submit" value="Submit">Resend Verification Link</button>
</form>
这是验证电子邮件的路由,我不知道如何传递电子邮件参数:
return redirect(route('verifyEmail'));