在我的应用程序中,有一个视图允许登录用户输入新密码。如何对新密码进行哈希处理?使用原生的拉拉维尔Auth
我只会
Hash::make($input['password']);
Sentry 2
也一样吗?如果是,在执行重置并更新用户表后,我得到了一个WrongPasswordException
,所以我假设哈希方法不同。如果哨兵有自己的哈希方法,我肯定找不到它。
更新:显然这种方法将以相同的方式工作并自动保存用户记录,文档只是没有指出这一点。
使用 Sentry 方法更新用户,它将像Sentry::getUserProvider()->create();
一样自动散列密码。
try
{
// Find the user using the user id
$user = Sentry::findUserById(1);
// Update the user details
$user->email = 'john.doe@example.com';
$user->first_name = 'John';
// Update the user
if ($user->save())
{
// User information was updated
}
else
{
// User information was not updated
}
}
catch (Cartalyst'Sentry'Users'UserExistsException $e)
{
echo 'User with this login already exists.';
}
catch (Cartalyst'Sentry'Users'UserNotFoundException $e)
{
echo 'User was not found.';
}