首先感谢您调查我的问题
我遇到了一个错误,即使使用正确的凭据,身份验证也会返回 false。 我测试了 $request 并且它起作用了。 与数据库的连接也可以正常工作。
附言我知道密码通常需要散列,我首先使用标准散列尝试,结果与上述相同
使用: Laravel 8 Apache MySQL xampp
登录控制器.php
public function store(Request $request){
$this->validate($request,[
'email' => 'required|email',
'password' => 'required',
]);
dd(auth()->attempt(['playerMail'=>$request->email,'password'=>$request->password]));
}
用户迁移
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('playerName');
$table->string('playerMail')->unique();
$table->timestamp('email_verified_at');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
型号
class User extends Authenticatable
{
use HasFactory, Notifiable;
protected $fillable = [
'playerName',
'playerMail',
'password',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}
答案 0 :(得分:-1)
我的虚拟头没有使用电子邮件作为数据库中的列名。谢谢@N69S
我还需要对密码进行哈希处理,否则开箱即用。 谢谢@lagbox