Skip to content

Commit 6734e43

Browse files
authored
Merge pull request #11580 from nextcloud/backport/11568/stable14
[stable14] Just update password hash without validating
2 parents 7d850c3 + 5e143f1 commit 6734e43

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/private/User/Database.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ public function deleteUser($uid) {
176176
return $result ? true : false;
177177
}
178178

179+
private function updatePassword(string $uid, string $passwordHash): bool {
180+
$query = $this->dbConn->getQueryBuilder();
181+
$query->update($this->table)
182+
->set('password', $query->createNamedParameter($passwordHash))
183+
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
184+
$result = $query->execute();
185+
186+
return $result ? true : false;
187+
}
188+
179189
/**
180190
* Set password
181191
*
@@ -195,13 +205,7 @@ public function setPassword(string $uid, string $password): bool {
195205
$hasher = \OC::$server->getHasher();
196206
$hashedPassword = $hasher->hash($password);
197207

198-
$query = $this->dbConn->getQueryBuilder();
199-
$query->update($this->table)
200-
->set('password', $query->createNamedParameter($hashedPassword))
201-
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
202-
$result = $query->execute();
203-
204-
return $result ? true : false;
208+
return $this->updatePassword($uid, $hashedPassword);
205209
}
206210

207211
return false;
@@ -314,7 +318,7 @@ public function checkPassword(string $uid, string $password) {
314318
$newHash = '';
315319
if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
316320
if (!empty($newHash)) {
317-
$this->setPassword($uid, $password);
321+
$this->updatePassword($uid, $newHash);
318322
}
319323
return (string)$row['uid'];
320324
}

0 commit comments

Comments
 (0)