laravel-backpack - 如何在 laravel 背包中使用电子邮件验证用户?
问题描述
所以我想验证用户是否已经注册,他们必须先验证他们的帐户,然后才能登录他们的帐户。
Mail::send([],[], function($message) use($input) {
$message->to($input['email'])
->subject('Your New Password ')
->setBody(
'<html><h2>Please click button below to verify your email</h2>
<br> <form method ="POST" action="{{
url(`verification/{'.$input['email'].'}`) }}">
<input type="submit" value="Verify Now" />
</form>
</html>','text/html'
);
$message->from(env('MAIL_USERNAME','victoriussaputra@gmail.com'),'Victorius');
});
return $this->sendResponse($success, 'Please verify your email to login');
这个想法是,当用户在他们的电子邮件中单击“立即验证”按钮时,它会自动运行 API 来通过将验证从 0 更新为 1 来验证用户。
$query = DB::table('users')
->select(DB::raw('COUNT(users.id) as totalemail'))
->where('email',$email)
->first();
if($query->totalemail>=1)
{
$update = DB::table('users')
->where('email',$email)
->update([
'verification'=> 1
]);
return $this->sendResponse($update, 'Success');
}
else{
return $this->sendError('Unauthorised.', ['error'=>'Unauthorised']);
}
但是,当我通过 gmail 单击电子邮件中的按钮时,它只是刷新了 gmail 页面,但没有更新已验证的列。
这是我用于更新验证和注册的 API 路由
Route::post('verification/{email}','App\Http\Controllers\API\RegisterController@updateVerification');
Route::post('register', 'App\Http\Controllers\API\RegisterController@register');
解决方案
推荐阅读
- android - 集成 Sentry 后无法构建 RN App
- javascript - 使用 vue js 按价格范围和类型过滤
- r - 如何使用 ggplot 在一个图表上为两个不同的数据框着色?
- php - 检查一个 IP 是否存在于多个 CIDR 范围内
- javascript - 将评论加载到页面而不刷新
- html - 如何在 2x2 网格中显示这些图像?
- jquery - jQuery:将左键单击更改为右键单击
- python - Pandas nunique() 但仅返回 value.counts() > 1
- php - 致命错误:未捕获错误:调用未定义函数 db2_connect()
- javascript - 如何停止此递归功能