Laravel Auth类不验证帐户

时间:2014-01-25 11:34:29

标签: php authentication laravel laravel-4

我使用以下代码保存了用户在Laravel 4中的注册(可以):

$validations = Validator::make($Data, $required);
     // print_r($_POST);

      if($validations->passes())
      {
          $user = new User();
          $user->username = $Data['username'];
          $user->password = Hash::make(Input::get('password'));
          $user->content = "this is info";
          $user->email = 'mostafatalebi@rocketmail.com';
          $user->save();
           echo "thanks it is been validates";     
       } else { return Redirect::route("register_view")->withErrors($validations); }

但是当我想使用Auth验证用户时,它返回false。以下是使用Laravel原生Auth类对用户进行身份验证的代码。

$Data = array(
           "password" => Input::get('password'),
           "username" => Input::get('username')
       );
        print_r($Data);
        echo "<br />".Hash::make($Data['password'])."<br />";
        if(Auth::attemp($Data))
        {
         echo "thanks";   
        } 
        else { echo "Problem in Login"; }

您认为这是什么问题?感谢

2 个答案:

答案 0 :(得分:0)

$user->password = Hash::make($Data['password']);

提示:在传递密码之前对其进行哈希处理。

答案 1 :(得分:0)

您在代码中错误Auth:attempt