我是 laravel 的新手。请帮我。
这是我的用户模型
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
public $timestamps = false;
/*
* mass assignable attributes
*/
protected $fillable = [
'user_id',
'email',
'uuid',
'pwd_expired',
'two_factor_auth_required',
'is_editable',
'version',
'first_name',
'last_name',
'pwd_hash',
'merchant_id'
];
}
这是我的身份验证功能。
public function authenticateUser(Request $data){
// checking if there any user for given email
if( $this->IsEmailUnique($data ->email)){
return $this->setHeaders([
'status' => 'fail',
'msg' => 'No user recorded with given email address',
], 404 );
}
// if there is a user relevant to given email address
else{
// getting user relevant to given email
$user = $this -> getSingleUserByEmail($data->email);
// checking for password matching
if( Hash::check($data -> password, $user -> pwd_hash)){
return $this->setHeaders([
'status' => 'success',
'msg' => 'User successfully authenticated',
'user' => $user,
'merchant' => Merchant::where('merchant_id', $user -> merchant_id)->get()
], 200 );
}
// if authentication failed
else{
return $this->setHeaders([
'status' => 'fail',
'msg' => 'Invalid password for given username',
], 403 );
}
}
}
我正在使用我自己的用户模型。我在用户列中的密码字段超过 60 个字符。在 Hash::check 之前一切正常。我已经用 var_dumps 进行了测试。但是“Hash::check($data -> password, $user -> pwd_hash)”总是返回 false。请帮我。
我也在我的 UserController 中编写所有登录信息。我只需要功能。