Do not update passwords if nothing changed

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2022-08-08 17:41:52 +02:00
parent 1405b7a8ca
commit 9d1ec582ba
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -409,9 +409,12 @@ class PublicKeyTokenProvider implements IProvider {
$tokens = $this->mapper->getTokenByUser($uid);
foreach ($tokens as $t) {
$publicKey = $t->getPublicKey();
$t->setPassword($this->encryptPassword($password, $publicKey));
$t->setPasswordInvalid(false);
$this->updateToken($t);
$encryptedPassword = $this->encryptPassword($password, $publicKey);
if ($t->getPassword() !== $encryptedPassword) {
$t->setPassword($encryptedPassword);
$t->setPasswordInvalid(false);
$this->updateToken($t);
}
}
}