Php laravel 5.2验证:尝试始终返回false
我面临的问题是auth:trument方法总是返回false值 我的数据库条目是:Php laravel 5.2验证:尝试始终返回false,php,laravel,authentication,Php,Laravel,Authentication,我面临的问题是auth:trument方法总是返回false值 我的数据库条目是: 用户名:admin 密码: $2y$10$jXkNy3WC2wqu0jmaqOfDiOgDnBV89uyvJPcNSU8xOnmO3w9RjT53S 注意:我在回显Hash::make('admin')的输出后手动存储了密码 验证代码为: // create our user data for the authentication $userdata = array( 'username' =
- 用户名:admin
- 密码: $2y$10$jXkNy3WC2wqu0jmaqOfDiOgDnBV89uyvJPcNSU8xOnmO3w9RjT53S
// create our user data for the authentication
$userdata = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
'agencyactive' => 1
);
if (Auth::attempt($userdata))
{
echo 'SUCCESS!';exit;
}
else
{
echo "<br>Login error";exit;
}
令人惊讶的是,当我验证下面的比较时,它会打印匹配项
if (\Hash::check('admin', '$2y$10$jXkNy3WC2wqu0jmaqOfDiOgDnBV89uyvJPcNSU8xOnmO3w9RjT53S'))
{
// The passwords match...
echo "MATCHES";
}
else
{
echo "NO Match";
}
我不知道这里出了什么问题???您是否有其他型号的默认用户 如果是这样,您可以转到config/auth.php并更改:
'model' => 'MyApp\Models\Agency',
例如谢谢你的回复
我发现,由于我使用的是“代理”表(而不是用户),模型代理需要实现某些方法,如
public function getAuthPassword()
{
return $this->password;
}
是的,我的身份验证设置是:
'defaults'=>['guard'=>'web','passwords'=>'users',],'guards'=>['web'=>['driver'=>'session','provider'=>'users',],'api'=>['driver'=>'token','provider'=>'users',],],“提供者”=>[“用户”=>[“驱动程序”=>“雄辩”、“模型”=>App\Agency::class、]、],,
public function getAuthPassword()
{
return $this->password;
}