@@ -434,7 +434,6 @@ protected function authenticatePasswordVerifyHash(
434434 throw new Error \Error ('WRONGUSERPASS ' );
435435 }
436436
437- $ validPasswordHashFound = false ;
438437 $ passwordHash = null ;
439438 foreach ($ data as $ row ) {
440439 if ((!array_key_exists ($ hashColumn , $ row )) || is_null ($ row [$ hashColumn ])) {
@@ -445,27 +444,27 @@ protected function authenticatePasswordVerifyHash(
445444 ));
446445 throw new Error \Error ('WRONGUSERPASS ' );
447446 }
448- if (($ passwordHash === null ) && (strlen ($ row [$ hashColumn ]) > 0 )) {
449- $ passwordHash = $ row [$ hashColumn ];
450- $ validPasswordHashFound = true ;
451- } elseif ($ passwordHash != $ row [$ hashColumn ]) {
447+
448+ if (strlen ($ row [$ hashColumn ]) === 0 ) {
452449 Logger::error (sprintf (
453- 'sqlauth:%s: column %s must be THE SAME in every result tuple . ' ,
450+ 'sqlauth:%s: column `%s` must contain a valid password hash . ' ,
454451 $ this ->authId ,
455452 $ hashColumn ,
456453 ));
457454 throw new Error \Error ('WRONGUSERPASS ' );
458- } elseif (strlen ($ row [$ hashColumn ]) === 0 ) {
455+ } elseif ($ passwordHash === null ) {
456+ $ passwordHash = $ row [$ hashColumn ];
457+ } elseif ($ passwordHash != $ row [$ hashColumn ]) {
459458 Logger::error (sprintf (
460- 'sqlauth:%s: column `%s` must contain a valid password hash . ' ,
459+ 'sqlauth:%s: column %s must be THE SAME in every result tuple . ' ,
461460 $ this ->authId ,
462461 $ hashColumn ,
463462 ));
464463 throw new Error \Error ('WRONGUSERPASS ' );
465464 }
466465 }
467466
468- if ((! $ validPasswordHashFound ) || (!password_verify ($ password , $ passwordHash ))) {
467+ if (($ passwordHash == null ) || (!password_verify ($ password , $ passwordHash ))) {
469468 Logger::error ('sqlauth: ' . $ this ->authId . ': Auth query ' . $ queryname .
470469 ' password verification failed ' );
471470 /* Authentication with verify_password() failed, however that only means that
0 commit comments