1

在我的应用程序中,有一个视图允许登录用户输入新密码。我如何散列新密码?使用原生 LaravelAuth我只想

Hash::make($input['password']);

是一样的Sentry 2吗?如果是这样,在执行重置并更新用户表后,我会得到一个WrongPasswordException,所以我假设哈希方法不同。如果 Sentry 有它自己的哈希方法,我肯定找不到它。

更新:显然这种方法将以相同的方式工作并自动保存用户记录,文档只是没有指出这一点。

4

1 回答 1

3

使用 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.';
    }
于 2013-12-17T22:57:03.843 回答