@@ -193,7 +193,13 @@ public function setPassword(string $uid, string $password): bool {
193193 $ hasher = \OC ::$ server ->getHasher ();
194194 $ hashedPassword = $ hasher ->hash ($ password );
195195
196- return $ this ->updatePassword ($ uid , $ hashedPassword );
196+ $ return = $ this ->updatePassword ($ uid , $ hashedPassword );
197+
198+ if ($ return ) {
199+ $ this ->cache [$ uid ]['password ' ] = $ hashedPassword ;
200+ }
201+
202+ return $ return ;
197203 }
198204
199205 return false ;
@@ -329,28 +335,16 @@ public function searchKnownUsersByDisplayName(string $searcher, string $pattern,
329335 * returns the user id or false
330336 */
331337 public function checkPassword (string $ loginName , string $ password ) {
332- $ this ->fixDI ( );
338+ $ found = $ this ->loadUser ( $ loginName );
333339
334- $ qb = $ this ->dbConn ->getQueryBuilder ();
335- $ qb ->select ('uid ' , 'password ' )
336- ->from ($ this ->table )
337- ->where (
338- $ qb ->expr ()->eq (
339- 'uid_lower ' , $ qb ->createNamedParameter (mb_strtolower ($ loginName ))
340- )
341- );
342- $ result = $ qb ->execute ();
343- $ row = $ result ->fetch ();
344- $ result ->closeCursor ();
345-
346- if ($ row ) {
347- $ storedHash = $ row ['password ' ];
340+ if ($ found && is_array ($ this ->cache [$ loginName ])) {
341+ $ storedHash = $ this ->cache [$ loginName ]['password ' ];
348342 $ newHash = '' ;
349343 if (\OC ::$ server ->getHasher ()->verify ($ password , $ storedHash , $ newHash )) {
350344 if (!empty ($ newHash )) {
351345 $ this ->updatePassword ($ loginName , $ newHash );
352346 }
353- return (string )$ row ['uid ' ];
347+ return (string )$ this -> cache [ $ loginName ] ['uid ' ];
354348 }
355349 }
356350
@@ -375,7 +369,7 @@ private function loadUser($uid) {
375369 }
376370
377371 $ qb = $ this ->dbConn ->getQueryBuilder ();
378- $ qb ->select ('uid ' , 'displayname ' )
372+ $ qb ->select ('uid ' , 'displayname ' , ' password ' )
379373 ->from ($ this ->table )
380374 ->where (
381375 $ qb ->expr ()->eq (
@@ -391,6 +385,7 @@ private function loadUser($uid) {
391385 $ this ->cache [$ uid ] = [
392386 'uid ' => (string )$ row ['uid ' ],
393387 'displayname ' => (string )$ row ['displayname ' ],
388+ 'password ' => (string )$ row ['password ' ],
394389 ];
395390 } else {
396391 $ this ->cache [$ uid ] = false ;
0 commit comments