使用Laravel Auth时无法登录

时间:2015-02-21 10:27:50

标签: php laravel-4

我想在这里关注解决方案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中的数据 enter image description here 如果它运行正确的密码,为什么它会失败?

0 个答案:

没有答案
相关问题