diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index 837374dda966f792cf276e7e03fe7908b24036f8..207e3d1c1729249619193682a81e47224a048314 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -173,6 +173,23 @@ if ( exit(); } +if ($_REQUEST['trigger'] != 'changePass' || isset($_REQUEST['page'])) { + if ($_REQUEST['page'] != 'login' && $_REQUEST['page'] != 'log' && !empty($_SESSION['user']['UserId'])) { + $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); + + if (!empty($passwordRules['renewal'])) { + $currentDate = new \DateTime(); + $lastModificationDate = new \DateTime($_SESSION['user']['password_modification_date']); + $lastModificationDate->add(new DateInterval("P{$passwordRules['renewal']}D")); + + if ($currentDate > $lastModificationDate) { + header('location: '.$_SESSION['config']['businessappurl'].'index.php?trigger=changePass'); + exit(); + } + } + } +} + if (isset($_REQUEST['display'])) { $core->insert_page(); exit(); diff --git a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts index c9bce0b9d88737020190a4ea0331bad20c216229..bac58f480b50de3df430f938f2fc0823e5280f5b 100644 --- a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts @@ -89,10 +89,8 @@ export class BasketAdministrationComponent implements OnInit { this.basket.clause = data.basket.basket_clause; this.basket.isSearchBasket = data.basket.is_visible != "Y"; this.basket.flagNotif = data.basket.flag_notif == "Y"; - if(this.basket.basket_res_order == '' || this.basket.basket_res_order == null){ - this.orderColumnsSelected = null; - } - else{ + this.orderColumnsSelected = null; + if (this.basket.basket_res_order != '' && this.basket.basket_res_order != null) { this.orderColumnsSelected = this.basket.basket_res_order.split(','); } @@ -189,7 +187,7 @@ export class BasketAdministrationComponent implements OnInit { } } - onOrderChange(){ + onOrderChange() { if (this.columnsFormControl.value.length < 3) { this.selection = this.columnsFormControl.value; } else { @@ -298,11 +296,11 @@ export class BasketAdministrationComponent implements OnInit { }) export class BasketAdministrationSettingsModalComponent extends AutoCompletePlugin { - lang : any = LANG; - allEntities : any[] = []; - statuses : any; + lang : any = LANG; + allEntities : any[] = []; + statuses : any; selectedStatuses : any[] = []; - statusCtrl = new FormControl(); + statusCtrl = new FormControl(); constructor(public http: HttpClient, @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<BasketAdministrationSettingsModalComponent>) { super(http, ['users','statuses']); @@ -391,15 +389,13 @@ export class BasketAdministrationSettingsModalComponent extends AutoCompletePlug }); } - remove(index: number): void { - + remove(index: number): void { this.selectedStatuses.splice(index, 1); this.statusCtrl.setValue(null); this.statusInput.nativeElement.value = ''; - - } + } - add(status: any): void { + add(status: any): void { let isIn = false; this.selectedStatuses.forEach((statusList: any) => { @@ -411,10 +407,8 @@ export class BasketAdministrationSettingsModalComponent extends AutoCompletePlug this.selectedStatuses.push(status); this.statusCtrl.setValue(null); this.statusInput.nativeElement.value = ''; - } - } - - + } + } initService() { this.allEntities.forEach((entity: any) => { @@ -606,4 +600,4 @@ export class BasketAdministrationGroupListModalComponent { this.newBasketGroup.group_desc = group.group_desc; this.dialogRef.close(this.newBasketGroup); } -} \ No newline at end of file +} diff --git a/core/class/class_security.php b/core/class/class_security.php index 444d7464b213055706cf8887142d63aaf0da8bc3..41713c6b52635ad95b8fbf025bb45319d8295b0c 100755 --- a/core/class/class_security.php +++ b/core/class/class_security.php @@ -171,6 +171,7 @@ class security extends Database 'pathToSignature' => $_SESSION['user']['pathToSignature'], 'Status' => $user->__get('status'), 'cookie_date' => $user->__get('cookie_date'), + 'password_modification_date' => $user->__get('password_modification_date') ); $array['primarygroup'] = $ugc->getPrimaryGroup( @@ -229,22 +230,6 @@ class security extends Database ); } - $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); - - if (!empty($passwordRules['renewal'])) { - $currentDate = new \DateTime(); - $lastModificationDate = new \DateTime($user->__get('password_modification_date')); - $lastModificationDate->add(new DateInterval("P{$passwordRules['renewal']}D")); - - if ($currentDate > $lastModificationDate) { - return [ - 'user' => $array, - 'error' => $error, - 'url' => 'index.php?trigger=changePass', - ]; - } - } - $loggingMethod = \SrcCore\models\CoreConfigModel::getLoggingMethod(); if ($array['change_pass'] == 'Y' && !in_array($loggingMethod['id'], ['sso', 'cas', 'ldap', 'ozwillo'])) { return array( diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 928bd57a0a6b00d8e9f87cfda194caa0969761fe..6461bc8a20d0f64d1f29aa2dc778997783d42e61 100644 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -301,8 +301,11 @@ class UserController { $data = $request->getParams(); - if (!$this->checkNeededParameters(['data' => $data, 'needed' => ['currentPassword', 'newPassword', 'reNewPassword']])) { - return $response->withStatus(400)->withJson(['errors' => 'Bas request']); + $check = Validator::stringType()->notEmpty()->validate($data['currentPassword']); + $check = $check && Validator::stringType()->notEmpty()->validate($data['newPassword']); + $check = $check && Validator::stringType()->notEmpty()->validate($data['reNewPassword']); + if (!$check) { + return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } $user = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id']]); diff --git a/src/core/controllers/PasswordController.php b/src/core/controllers/PasswordController.php index 9dfa79bbe34442ad7690899e8b9e7d1ec4b6baf1..34d52cddb4395512dd0fc190227cb23a4aa1efcc 100644 --- a/src/core/controllers/PasswordController.php +++ b/src/core/controllers/PasswordController.php @@ -26,10 +26,6 @@ class PasswordController { public function getRules(Request $request, Response $response) { - if (!ServiceModel::hasService(['id' => 'admin_password_rules', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { - return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); - } - return $response->withJson(['rules' => PasswordModel::getRules()]); }