我想在这里关注解决方案given。
getAuthPassword()
返回正确的哈希值,但我没有通过身份验证。代码段如下:
在控制器中:
public function doLogin()
{
// View::composer('layouts.master', function($view)
// {
//
// $view->with('login_status');
// });
$rules = array(
'username' => 'required',
'password' => 'required'
);
// run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
return Redirect::to('login')
->withErrors($validator)
->withInput(Input::except('password'));
}
else
{
$credentials['username'] = trim(Input::get('username'));
$credentials['password'] = trim(Input::get('password'));
//if (Auth::attempt(array($credentials), true))
if (Auth::attempt($credentials))
{
echo 'Success';
}
else
{
print 'faled';
dd(DB::getQueryLog());
exit;
return Redirect::to('login');
}
}
用户模型
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
public function getAuthPassword()
{
return $this->password;
}
}
Db中的数据 如果它运行正确的密码,为什么它会失败?