From f9ce6bfdff10665d40400c80662e9b29a00d8b3f Mon Sep 17 00:00:00 2001 From: Andrew Summers <18727110+summersab@users.noreply.github.com> Date: Tue, 29 Aug 2023 18:11:00 -0500 Subject: Refactor `OC\Server::getHasher` Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> --- lib/private/User/Database.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/private/User') diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 9ef1bc67a58..55d0183ce52 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -50,6 +50,7 @@ use OCP\Cache\CappedMemoryCache; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; use OCP\Security\Events\ValidatePasswordPolicyEvent; +use OCP\Security\IHasher; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICheckPasswordBackend; use OCP\User\Backend\ICountUsersBackend; @@ -130,7 +131,7 @@ class Database extends ABackend implements $qb->insert($this->table) ->values([ 'uid' => $qb->createNamedParameter($uid), - 'password' => $qb->createNamedParameter(\OC::$server->getHasher()->hash($password)), + 'password' => $qb->createNamedParameter(\OC::$server->get(IHasher::class)->hash($password)), 'uid_lower' => $qb->createNamedParameter(mb_strtolower($uid)), ]); @@ -197,7 +198,7 @@ class Database extends ABackend implements if ($this->userExists($uid)) { $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); - $hasher = \OC::$server->getHasher(); + $hasher = \OC::$server->get(IHasher::class); $hashedPassword = $hasher->hash($password); $return = $this->updatePassword($uid, $hashedPassword); @@ -353,7 +354,7 @@ class Database extends ABackend implements if ($found && is_array($this->cache[$loginName])) { $storedHash = $this->cache[$loginName]['password']; $newHash = ''; - if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) { + if (\OC::$server->get(IHasher::class)->verify($password, $storedHash, $newHash)) { if (!empty($newHash)) { $this->updatePassword($loginName, $newHash); } -- cgit v1.2.3