From 88746785b325ed32956406a03d7f408db52771bc Mon Sep 17 00:00:00 2001 From: Peter Rotich Date: Tue, 23 Aug 2022 01:26:56 +0000 Subject: [PATCH] auth-password-policy: Cast expires to int This commit addresses an issue where password expiration check failed in v1.17.x due to Uncaught TypeError caused by changing how config data is stored. --- auth-password-policy/auth.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auth-password-policy/auth.php b/auth-password-policy/auth.php index f61149d..c8d6bde 100644 --- a/auth-password-policy/auth.php +++ b/auth-password-policy/auth.php @@ -68,7 +68,7 @@ function getOptions() { 'required' => false, 'label' => __('Password expiration'), 'choices' => array( - '' => __('Never expires'), + '0' => __('Never expires'), '30' => __('30 days'), '60' => __('60 days'), '90' => __('90 days'), @@ -101,9 +101,10 @@ function onLogin($user, $password) { $this->processPassword($password); // Check password expiration - if ($this->config->get('expires') + $expires = (int) $this->config->get('expires', 0); + if ($expires && ($time = $user->getPasswdResetTimestamp()) - && ($time < (time()-($this->config->get('expires')*86400)))) + && ($time < (time() - ($expires * 86400)))) throw new ExpiredPassword(__('Expired Password')); }