Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Just update password hash without validating
Fixes #11097

If your password hash changed (becuse your are on 7.2 and we moved to
ARGON2). Then we shold not 'set a new password' but just update the
hash. As else we invoke the password policy again which might lock out
users.

Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Oct 3, 2018
commit 5e143f1f5214a13b4a6df0723619b150fc31572c
20 changes: 12 additions & 8 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ public function deleteUser($uid) {
return $result ? true : false;
}

private function updatePassword(string $uid, string $passwordHash): bool {
$query = $this->dbConn->getQueryBuilder();
$query->update($this->table)
->set('password', $query->createNamedParameter($passwordHash))
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
$result = $query->execute();

return $result ? true : false;
}

/**
* Set password
*
Expand All @@ -195,13 +205,7 @@ public function setPassword(string $uid, string $password): bool {
$hasher = \OC::$server->getHasher();
$hashedPassword = $hasher->hash($password);

$query = $this->dbConn->getQueryBuilder();
$query->update($this->table)
->set('password', $query->createNamedParameter($hashedPassword))
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
$result = $query->execute();

return $result ? true : false;
return $this->updatePassword($uid, $hashedPassword);
}

return false;
Expand Down Expand Up @@ -314,7 +318,7 @@ public function checkPassword(string $uid, string $password) {
$newHash = '';
if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
if (!empty($newHash)) {
$this->setPassword($uid, $password);
$this->updatePassword($uid, $newHash);
}
return (string)$row['uid'];
}
Expand Down