diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index 959a1c20d26525e62160d13bd4cc2bb30e0c6660..626419d79fd3780cb19006d9656fb9df68363316 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -203,6 +203,21 @@ if (!empty($_REQUEST['page']) && empty($_REQUEST['triggerAngular'])) { } else { header('location: index.php?display=true&page=logout&logout=true'); } + + $user = \User\models\UserModel::getByLogin(['login' => $cookie['userId'], 'select' => ['password_modification_date']]); + $loggingMethod = \SrcCore\models\CoreConfigModel::getLoggingMethod(); + if (!in_array($loggingMethod['id'], ['sso', 'cas', 'ldap', 'keycloak', 'shibboleth'])) { + $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); + if (!empty($passwordRules['renewal'])) { + $currentDate = new \DateTime(); + $lastModificationDate = new \DateTime($user['password_modification_date']); + $lastModificationDate->add(new DateInterval("P{$passwordRules['renewal']}D")); + + if ($currentDate > $lastModificationDate) { + header('location: index.php?display=true&page=logout&logout=true'); + } + } + } } //INSERT PART OF PAGE diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index d401f0b3a12eff15db65fe75d26119dd979dc6b7..da14fb15bc089fb2bb17efa13dd8bbfca0f1ddd7 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -65,7 +65,7 @@ class AuthenticationController ValidatorModel::stringType($aArgs, ['login', 'currentRoute']); if ($aArgs['currentRoute'] != '/initialize') { - $user = UserModel::getByLogin(['select' => ['status'], 'login' => $aArgs['login']]); + $user = UserModel::getByLogin(['select' => ['status', 'password_modification_date'], 'login' => $aArgs['login']]); if ($user['status'] == 'ABS' && !in_array($aArgs['currentRoute'], ['/users/{id}/status', '/currentUser/profile', '/header', '/passwordRules', '/users/{id}/password'])) { return ['isRouteAvailable' => false, 'errors' => 'User is ABS and must be activated'];