From 95c94f8ac78990f4ffc369149f2ccf440099eb4a Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Mon, 23 Jul 2018 14:13:06 +0200 Subject: [PATCH] [REFACTORING] Trigger angular --- apps/maarch_entreprise/index.php | 42 ++++++++++++++++++-------------- core/class/class_security.php | 10 +------- rest/index.php | 2 +- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index 5f663d29fdc..eed6ad80458 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -173,32 +173,38 @@ if ( exit(); } -if ($_REQUEST['triggerAngular'] != 'changePass' || isset($_REQUEST['page'])) { +if (isset($_REQUEST['display'])) { + $core->insert_page(); + exit(); +} + +if (empty($_REQUEST['triggerAngular'])) { if ($_REQUEST['page'] != 'login' && $_REQUEST['page'] != 'log' && $_REQUEST['page'] != 'logout' && !empty($_SESSION['user']['UserId'])) { - $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); - - $user = \User\models\UserModel::getByUserId(['userId' => $_SESSION['user']['UserId'], 'select' => ['password_modification_date', 'change_password']]); - if ($user['change_password'] == 'Y') { - header('location: '.$_SESSION['config']['businessappurl'].'index.php?triggerAngular=changePass'); - exit(); - } elseif (!empty($passwordRules['renewal'])) { - $currentDate = new \DateTime(); - $lastModificationDate = new \DateTime($user['password_modification_date']); - $lastModificationDate->add(new DateInterval("P{$passwordRules['renewal']}D")); - - if ($currentDate > $lastModificationDate) { + $user = \User\models\UserModel::getByUserId(['userId' => $_SESSION['user']['UserId'], 'select' => ['password_modification_date', 'change_password', 'status']]); + $loggingMethod = \SrcCore\models\CoreConfigModel::getLoggingMethod(); + +// if ($user['status'] == 'ABS') { +// +// } + if (!in_array($loggingMethod['id'], ['sso', 'cas', 'ldap', 'ozwillo'])) { + $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); + if ($user['change_password'] == 'Y') { header('location: '.$_SESSION['config']['businessappurl'].'index.php?triggerAngular=changePass'); exit(); + } elseif (!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: '.$_SESSION['config']['businessappurl'].'index.php?triggerAngular=changePass'); + exit(); + } } } } } -if (isset($_REQUEST['display'])) { - $core->insert_page(); - exit(); -} - if (isset($_GET['show'])) { $show = $_GET['show']; } else { diff --git a/core/class/class_security.php b/core/class/class_security.php index 2c7ca55b8ba..1ed87094084 100755 --- a/core/class/class_security.php +++ b/core/class/class_security.php @@ -215,7 +215,6 @@ class security extends Database } else { $ip = $_SERVER['REMOTE_ADDR']; } - $navigateur = addslashes($_SERVER['HTTP_USER_AGENT']); $_SESSION['user']['UserId'] = $s_login; $_SESSION['user']['department'] = $array['department']; $_SESSION['user']['thumbprint'] = $array['thumbprint']; @@ -229,14 +228,7 @@ class security extends Database ); } - $loggingMethod = \SrcCore\models\CoreConfigModel::getLoggingMethod(); - if ($array['change_pass'] == 'Y' && !in_array($loggingMethod['id'], ['sso', 'cas', 'ldap', 'ozwillo'])) { - return array( - 'user' => $array, - 'error' => $error, - 'url' => 'index.php?trigger=changePass', - ); - } elseif (isset($_SESSION['requestUri']) + if (isset($_SESSION['requestUri']) && trim($_SESSION['requestUri']) != '' && !preg_match('/page=login/', $_SESSION['requestUri'])) { return array( diff --git a/rest/index.php b/rest/index.php index e0a25348561..6d094efe6d0 100755 --- a/rest/index.php +++ b/rest/index.php @@ -26,7 +26,7 @@ if (file_exists("custom/{$customId}/src/core/lang/lang-{$language}.php")) { require_once("src/core/lang/lang-{$language}.php"); -$app = new \Slim\App(['settings' => ['displayErrorDetails' => true]]); +$app = new \Slim\App(['settings' => ['displayErrorDetails' => true, 'determineRouteBeforeAppMiddleware' => true]]); //Authentication $app->add(function (\Slim\Http\Request $request, \Slim\Http\Response $response, callable $next) { -- GitLab