enter image description here在我的laravel应用中,我遇到的问题是,当我注册用户laravel时,它会自动填充用户表中的email_verified_at列并重定向到仪表板。它会自动验证,而无需单击链接。我不知道为什么这会在发送验证电子邮件时填充此列值。
这是寄存器控制器
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都是相同的。 请帮助...
答案 0 :(得分:0)
因此,在对注释进行了所有讨论之后,并在看到了代码之后
我们可以得出结论,问题出在设置验证日期的数据库端,并且每当创建记录时,属性ON UPDATE CURRENT_TIMESTAMP()
都会自动填充该问题。