email_verified_at 在 laravel 5.8 发送验证邮件时自动设置
email_verified_at automatically set while sending verification email in laravel 5.8
enter image description here在我的 laravel 应用程序中,我有一个问题,即当我注册用户 laravel 时自动填充用户 table 中的 email_verified_at 列并重定向到仪表板。它会自动验证而无需单击 link。我不知道为什么在发送验证邮件时填写此列值。
这是注册控制器
protected $redirectTo = 'email/verify';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'alpha_num', 'min:8', 'confirmed'],
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
这是用户模型
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
protected $fillable = [
'name', 'email', 'password'
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}
这是验证控制器
use VerifiesEmails;
protected $redirectTo = '/dashboard';
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:3,1')->only('verify', 'resend');
}
这是路由文件
Auth::routes(['verify' => true]);
Route::group(['prefix'=>'dashboard','middleware' => ['auth','verified']],function () {
Route::get('/','dashboard\DashboardController@index')->name('dashboard-home');
});
这是登录控制器
class LoginController extends Controller
{
use AuthenticatesUsers{
logout as performLogout;
}
protected $redirectTo = '/dashboard';
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->middleware('prelogoutaction',['only' => 'logout']);
$this->middleware('postloginaction',['only' => 'login']);
}
public function logout(Request $request){
$this->performLogout($request);
return redirect()->route('web-home');
}
}
email_verified_at 和 created_at 是一样的。
请帮忙...
所以在评论讨论和看到代码之后
我们可以得出结论,问题出在设置验证日期的数据库端,并且由于属性 ON UPDATE CURRENT_TIMESTAMP()
每当创建记录时都会自动填充。
enter image description here在我的 laravel 应用程序中,我有一个问题,即当我注册用户 laravel 时自动填充用户 table 中的 email_verified_at 列并重定向到仪表板。它会自动验证而无需单击 link。我不知道为什么在发送验证邮件时填写此列值。
这是注册控制器
protected $redirectTo = 'email/verify';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'alpha_num', 'min:8', 'confirmed'],
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
这是用户模型
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
protected $fillable = [
'name', 'email', 'password'
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}
这是验证控制器
use VerifiesEmails;
protected $redirectTo = '/dashboard';
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:3,1')->only('verify', 'resend');
}
这是路由文件
Auth::routes(['verify' => true]);
Route::group(['prefix'=>'dashboard','middleware' => ['auth','verified']],function () {
Route::get('/','dashboard\DashboardController@index')->name('dashboard-home');
});
这是登录控制器
class LoginController extends Controller
{
use AuthenticatesUsers{
logout as performLogout;
}
protected $redirectTo = '/dashboard';
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->middleware('prelogoutaction',['only' => 'logout']);
$this->middleware('postloginaction',['only' => 'login']);
}
public function logout(Request $request){
$this->performLogout($request);
return redirect()->route('web-home');
}
}
email_verified_at 和 created_at 是一样的。 请帮忙...
所以在评论讨论和看到代码之后
我们可以得出结论,问题出在设置验证日期的数据库端,并且由于属性 ON UPDATE CURRENT_TIMESTAMP()
每当创建记录时都会自动填充。