File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1515class OtpWindow extends Value implements ProcessorInterface
1616{
1717 /**
18+ * Fetch Totp default period value
19+ *
1820 * @return int
1921 */
2022 private function getDefaultPeriod (): int
@@ -48,7 +50,13 @@ public function beforeSave()
4850 $ value = $ this ->getValue ();
4951 $ period = $ this ->getDefaultPeriod ();
5052 if (!is_numeric ($ value ) || $ value < 1 || $ value >= $ period ) {
51- throw new ValidatorException (__ ('Invalid OTP window value. It must be less than the OTP period value ' .$ period ));
53+ throw new ValidatorException (
54+ __ (
55+ 'Invalid OTP window value. It must be between 1 and %1 as default period is %2 ' ,
56+ $ period -1 ,
57+ $ period
58+ )
59+ );
5260 }
5361
5462 return parent ::beforeSave ();
Original file line number Diff line number Diff line change @@ -18,11 +18,19 @@ class UpdateOtpWindow implements DataPatchInterface
1818 */
1919 private $ moduleDataSetup ;
2020
21+ /**
22+ * @param ModuleDataSetupInterface $moduleDataSetup
23+ */
2124 public function __construct (ModuleDataSetupInterface $ moduleDataSetup )
2225 {
2326 $ this ->moduleDataSetup = $ moduleDataSetup ;
2427 }
2528
29+ /**
30+ * Fetch Totp default period
31+ *
32+ * @return int
33+ */
2634 public function getDefaultPeriod ()
2735 {
2836 return TOTPInterface::DEFAULT_PERIOD ;
@@ -43,17 +51,15 @@ public function apply()
4351 $ period = $ this ->getDefaultPeriod ();
4452 if ($ existingValue && $ existingValue >= $ period ) {
4553 $ newWindowValue = $ period - 1 ;
46- }
47-
48- if ($ existingValue ) {
4954 $ setup ->update (
5055 'core_config_data ' ,
5156 ['value ' => $ newWindowValue ],
5257 'path = "twofactorauth/google/otp_window" '
5358 );
5459 }
55-
5660 $ setup ->endSetup ();
61+
62+ return $ this ;
5763 }
5864
5965 /**
@@ -71,5 +77,4 @@ public function getAliases()
7177 {
7278 return [];
7379 }
74-
7580}
You can’t perform that action at this time.
0 commit comments