我想为通过API注册的帐户启用电子邮件验证。
电子邮件已正确发送,但是通过单击链接我收到了错误403(单击电子邮件链接后)
{"error": "Unauthenticated"}
对于通过“ WEB”注册的用户,没有问题。 激活链接是相同的:
http://localhost:8888/demo/public/email/verify/{id}/{hash}?expires=xxx&signature=xxxx
要激活电子邮件验证,请将其插入到web.php文件中:
Auth::routes(['verify' => true]);
我在用户模型中实现MustVerifyEmail:
class User extends Authenticatable implements MustVerifyEmail
在我的API注册控制器中,插入注册事件
event(new Registered($user));
$ user变量是User :: create()的结果
$user = $request->all();
$user['password'] = Hash::make($user['password']);
$user = User::create($user);
//data variabile is for JSON output
$data['token'] = $user->createToken('authToken')->plainTextToken;
$data['user'] = $user;
event(new Registered($user));