Laravel用户密码获取的疑问

疑问:laravel框架 User一般会设置隐藏 password 和 remember_token

```

/**

    * 检查原密码是否正确

    *

    * @param User $user

    * @param $old_password

    * @return mixed

    */

    protected function confirmedOldPassword(User $user, $old_password)

    {

        \Log::info(__FUNCTION__ . ',old:' . $old_password . ',user:' . json_encode($user));

        \Log::info('user password'.$user->password);

        return Hash::check($old_password, $user->password);

    }

```

日志:

```

[2019-01-09 14:08:15] local.INFO: confirmedOldPassword,old:123456,user:{"id":2,"name":"Felix2","email":"[email protected]","created_at":"2019-01-04 22:02:33","updated_at":"2019-01-09 14:02:55","username":"JJG","sex":0,"login_at":null,"login_ip":null,"avatar":"images\/avatar\/201901\/09\/MIftuayOGuaigFLBzGa8dkr6HhenGW3fX2smxXuB.jpeg","bool_admin":0,"status":1} 

[2019-01-09 14:08:15] local.INFO: user password:$2y$10$vgiAmcLDMCY.9c21KsnVeeEE2G/tXHI/RaHgg2EFWzUCl6.4kRdX2

```

现象:$user 里没有 password  但是 $user->password 能够取到值。

你可能感兴趣的:(Laravel用户密码获取的疑问)