99
1010namespace OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Service ;
1111
12- use OxidEsales \Eshop \Core \Registry ;
12+ use OxidEsales \Eshop \Core \Request ;
13+ use OxidEsales \Eshop \Core \Utils ;
1314use OxidEsales \EshopCommunity \Internal \Domain \Authentication \Bridge \PasswordServiceBridgeInterface ;
1415use OxidEsales \EshopCommunity \Internal \Framework \Session \SessionInterface ;
1516use OxidEsales \SecurityModule \Authentication \TwoFactorAuth \Infrastructure \Repository \UserRepositoryInterface ;
@@ -20,7 +21,9 @@ public function __construct(
2021 private AuthorizeServiceInterface $ authorizeService ,
2122 private UserRepositoryInterface $ userRepository ,
2223 private PasswordServiceBridgeInterface $ pwdServiceBridge ,
23- private SessionInterface $ session
24+ private SessionInterface $ session ,
25+ private Request $ request ,
26+ private Utils $ utils ,
2427 ) {
2528 }
2629
@@ -29,21 +32,27 @@ public function handleLogin(string $userName): void
2932 $ this ->session ->set (AuthorizeService::USER_SESSION_KEY , $ userName );
3033 $ this ->session ->set (
3134 AuthorizeService::OTP_TARGET_URL ,
32- //todo: bind registry
33- Registry::getRequest ()->getRequestUrl ()
35+ $ this ->request ->getRequestUrl ()
3436 );
3537
38+ //todo: prevent spam by rate limiting
3639 $ this ->authorizeService ->generate ();
3740
38- //todo: return full url
3941 $ redirectUrl = $ this ->authorizeService ->getVerificationUrl ();
40- Registry:: getUtils ()-> redirect (Registry:: getConfig ()-> getShopHomeUrl () . ' cl= ' . $ redirectUrl );
42+ $ this -> utils -> redirect ( $ redirectUrl );
4143 }
4244
4345 public function checkPassword (string $ userName , string $ password ): bool
4446 {
45- //todo: got exception if user not found
46- $ userPasswordHash = $ this ->userRepository ->getUserPasswordHash ($ userName );
47+ try {
48+ $ userPasswordHash = $ this ->userRepository ->getUserPasswordHash ($ userName );
49+ } catch (\Throwable $ e ) {
50+ return false ;
51+ }
52+
53+ if ($ userPasswordHash === null ) {
54+ return false ;
55+ }
4756
4857 return $ this ->pwdServiceBridge
4958 ->verifyPassword ($ password , $ userPasswordHash );
0 commit comments