diff options
author | Joas Schilling <coding@schilljs.com> | 2023-01-09 15:13:08 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-01-09 15:13:08 +0100 |
commit | c5bb19641c12757e2b11376ee431d2a941e98e3f (patch) | |
tree | c11005801883378deb4fe33797c41cf474130e00 /lib/private/Authentication/Token | |
parent | 55d8aec7597ab29031abda47da9afa15a16b0a4a (diff) | |
download | nextcloud-server-c5bb19641c12757e2b11376ee431d2a941e98e3f.tar.gz nextcloud-server-c5bb19641c12757e2b11376ee431d2a941e98e3f.zip |
fix(authentication): Invert the logic to the original intention
We need to store the new authentication details when the hash did **not** verify
the old password.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Authentication/Token')
-rw-r--r-- | lib/private/Authentication/Token/PublicKeyTokenProvider.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 651540f934a..adac86dd073 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -450,13 +450,14 @@ class PublicKeyTokenProvider implements IProvider { $passwordHash = $this->hashPassword($password); $verifiedHashes = []; foreach ($tokens as $t) { - if ($t->getPasswordHash() === null || isset($verifiedHashes[$t->getPasswordHash()]) || $this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) { - $verifiedHashes[$t->getPasswordHash() ?: ''] = true; + if ($t->getPasswordHash() === null || !isset($verifiedHashes[$t->getPasswordHash()]) || !$this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) { $publicKey = $t->getPublicKey(); $t->setPassword($this->encryptPassword($password, $publicKey)); $t->setPasswordHash($passwordHash); $t->setPasswordInvalid(false); $this->updateToken($t); + } else { + $verifiedHashes[$t->getPasswordHash() ?: ''] = true; } } } |