Laravel Auth问题,无法登录,因为Auth :: attempt返回false

时间:2014-05-14 11:48:44

标签: authentication laravel

我有2个表格“注册”和“登录”。

处理注册和登录的UserController.php如下:

    public function store()
      {
            $data = new User;
            $data->Username = Input::get('username');
            $data->email = Input::get('email');
            $data->password = Hash::make((Input::get('password')));
            $data->save()
            // redirect
            return Redirect::to('users');
      }

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

            if (Auth::attempt($userdata)) {
                dd('success');
            } else {
                dd('error');
            }
        }

注册工作并保存密码哈希,但当我尝试登录时,它始终显示"string(5) "error"。哪里可能有问题?

我的routes.php如下:

Route::get('users', 'UserController@index');
Route::post('users/register',array('uses' => 'UserController@store'));
Route::post('users/signin',array('uses' => 'UserController@postSignin'));

编辑:

$userdata = array(
                'email' => Input::get('email'),
                'password' => Input::get('password')
            );
 if (Auth::attempt($userdata)) {
                dd('success');
            } else {

                // validation not successful, send back to form 
                 dd($userdata);
            }

并显示

array(2) { ["email"]=> string(15) "admin@gmail.com" ["password"]=> string(5) "admin" } 

是不是在解密paassword?因为总是执行其他条件

1 个答案:

答案 0 :(得分:0)

您在注册时存储方法用户名密码

而在您的登录方式中,您需要检查电子邮件密码