1313use DateTimeImmutable ;
1414use Doctrine \DBAL \Result ;
1515use OxidEsales \EshopCommunity \Internal \Framework \Database \QueryBuilderFactoryInterface ;
16+ use OxidEsales \EshopCommunity \Internal \Transition \Utility \ContextInterface ;
1617use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \DTO \UserInterface ;
1718use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \DTO \User as UserDTO ;
1819use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Exception \UserNotFoundException ;
@@ -23,22 +24,26 @@ class UserRepository implements UserRepositoryInterface
2324 public function __construct (
2425 private readonly UserFactoryInterface $ userFactory ,
2526 private readonly QueryBuilderFactoryInterface $ queryBuilderFactory ,
27+ private readonly ContextInterface $ context ,
2628 ) {
2729 }
2830
29- public function getUserOTPData (string $ userName ): UserInterface
31+ public function getUserOTPData (string $ userId ): UserInterface
3032 {
3133 $ builder = $ this ->queryBuilderFactory ->create ();
3234 $ builder ->select ([
3335 'OXID ' ,
36+ 'OXUSERNAME ' ,
3437 'OESMOTPCODE ' ,
3538 'OESMOTPATTEMPTS ' ,
3639 'OESMOTPEXPTIME ' ,
3740 'OESMOTPLASTSENT ' ,
3841 ])
3942 ->from ('oxuser ' )
40- ->where ('oxusername = :userName ' )
41- ->setParameter ('userName ' , $ userName );
43+ ->where ('oxid = :userId ' )
44+ ->andWhere ('oxshopid = :shopId ' )
45+ ->setParameter ('userId ' , $ userId )
46+ ->setParameter ('shopId ' , $ this ->context ->getCurrentShopId ());
4247
4348 /** @var Result $queryResult */
4449 $ queryResult = $ builder ->execute ();
@@ -49,7 +54,8 @@ public function getUserOTPData(string $userName): UserInterface
4954
5055 return new UserDTO (
5156 $ userData ['OXID ' ],
52- $ userData ['OESMOTPATTEMPTS ' ],
57+ $ userData ['OXUSERNAME ' ],
58+ (int )$ userData ['OESMOTPATTEMPTS ' ],
5359 $ userData ['OESMOTPCODE ' ],
5460 $ userData ['OESMOTPEXPTIME ' ] ? new DateTime ($ userData ['OESMOTPEXPTIME ' ]) : null ,
5561 $ userData ['OESMOTPLASTSENT ' ] ? new DateTime ($ userData ['OESMOTPLASTSENT ' ]) : null ,
@@ -93,21 +99,6 @@ public function resetCodeFields(string $userId): void
9399 $ userModel ->save ();
94100 }
95101
96- public function getUserPasswordHash (string $ userName ): ?string
97- {
98- $ builder = $ this ->queryBuilderFactory ->create ();
99- $ builder ->select ('OXPASSWORD ' )
100- ->from ('oxuser ' )
101- ->where ('oxusername = :userName ' )
102- ->setParameter ('userName ' , $ userName );
103-
104- /** @var Result $queryResult */
105- $ queryResult = $ builder ->execute ();
106- $ userPass = $ queryResult ->fetchOne ();
107-
108- return $ userPass ?: null ;
109- }
110-
111102 public function markOtpAsSent (string $ userId ): void
112103 {
113104 $ userModel = $ this ->userFactory ->create ();
0 commit comments