Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable14] Just update password hash without validating #11580

Merged
merged 1 commit into from
Oct 3, 2018
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
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