这是我的登录尝试:
public function loginUser(Request $request){
$rules = [
'email' => 'required',
'password' => 'required'
];
$this->validate($request, $rules);
//attempting login
if(Auth::attempt(['email' => $request->email, 'password' => $request->password])){
return 'hello';
}
return 'null';
}
这是我的身份验证配置:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
//'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
这是我的数据结构:
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->integer('verified')->unsigned();
$table->string('verification_token')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
当我从我的api路由调用此loginUser函数时,即使我传递的凭据有效,它也会为我提供null; 而且我正在使用bcrypt密码;