Laravel身份验证失败

时间:2014-02-02 01:12:35

标签: php authentication laravel

我或多或少通过this authentication tutorial处理过Laravel的基本用户身份验证。我能找到的所有内容都符合教程,以及我可以在主题上找到的所有其他文章和问题,但我的身份验证仍然失败。

我已确保使用正确的电子邮件和密码。您可以访问the project website's registration page进行注册,然后根据需要登录。它当前正在显示电子邮件和密码,作为身份验证错误消息的一部分。

用户创建代码为:

public function postCreate() {
        $validator = Validator::make(Input::all(), User::$rules);

        if ($validator->passes()) {
            // Validation has passed, save the user in the database
            $user = new User;
            $user->username = Input::get('username');
            $user->firstname = Input::get('firstname');
            $user->lastname = Input::get('lastname');
            $user->email = Input::get('email');
            $user->password = Hash::make(Input::get('password'));
            $user->save();

            return Redirect::to('/')->with('message', 'Thanks for registering!');
        } else {
            // Validation has failed, display error messages
            return Redirect::to('users/register')->with('message', 'The following errors occurred . ' . $validator->messages())->withErrors($validator)->withInput();
        }
    }

实际的登录代码是:

public function postSignin() {
        $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));

        if (Auth::attempt($credentials)) {
            return Redirect::to('users/dashboard');
        } else {
            return Redirect::to('users/login')->with('message', 'Your username/password combination was incorrect ' . Input::get('email') . ' ' . Input::get('password'))
                ->withInput();
        }
    }

我尝试登录时发出的错误很简单“您的用户名/密码组合不正确。”

我已经检查过以确保进入数据库的信息是正确的。例如,这是用户表:

users table

1 个答案:

答案 0 :(得分:1)

检查数据库中的密码字段是否为60个字符。 Laravel生成的密码哈希为60个字符