Exemplo n.º 1
0
/**
 * Used by et_check_password in order to rehash
 * an old password that was hashed using MD5 function.
 *
 * @deprecated since release 6.2.0
 * @since 1.0.0
 * @param string $password
 *            Person password.
 * @param int $person_id
 *            Person ID.
 * @return mixed
 */
function et_set_password($password, $person_id)
{
    _deprecated_function(__FUNCTION__, '6.2.0', 'etsis_set_password');
    return etsis_set_password($password, $person_id);
}
Exemplo n.º 2
0
/**
 * Checks a plain text password against a hashed password.
 *
 * @since 6.2.0
 * @param string $password
 *            Plain test password.
 * @param string $hash
 *            Hashed password in the database to check against.
 * @param int $person_id
 *            Person ID.
 * @return mixed
 */
function etsis_check_password($password, $hash, $person_id = '')
{
    $app = \Liten\Liten::getInstance();
    // If the hash is still md5...
    if (strlen($hash) <= 32) {
        $check = $hash == md5($password);
        if ($check && $person_id) {
            // Rehash using new hash.
            etsis_set_password($password, $person_id);
            $hash = etsis_hash_password($password);
        }
        return $app->hook->apply_filter('check_password', $check, $password, $hash, $person_id);
    }
    // If the stored hash is longer than an MD5, presume the
    // new style phpass portable hash.
    $hasher = new \app\src\PasswordHash(8, FALSE);
    $check = $hasher->CheckPassword($password, $hash);
    return $app->hook->apply_filter('check_password', $check, $password, $hash, $person_id);
}