From a38d38108d37634ea55e7fa34a65b1d60d89cbb4 Mon Sep 17 00:00:00 2001 From: "hamza.hramchi" <hamza.hramchi@xelians.fr> Date: Tue, 19 Oct 2021 16:32:57 +0200 Subject: [PATCH] FIX #18428 TIME 0:20 Admin/Maarch2Maarch: check if password is already defined --- .../controllers/ConfigurationController.php | 3 ++- .../maarch-to-maarch-parameters.component.html | 1 + .../maarch-to-maarch-parameters.component.ts | 10 +++++++--- src/lang/lang-en.json | 4 +++- src/lang/lang-fr.json | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/configuration/controllers/ConfigurationController.php b/src/app/configuration/controllers/ConfigurationController.php index 1496457f37f..576bcbcaf80 100755 --- a/src/app/configuration/controllers/ConfigurationController.php +++ b/src/app/configuration/controllers/ConfigurationController.php @@ -275,7 +275,8 @@ class ConfigurationController 'communications' => [ 'email' => $xmlConfig['m2m_communication_type']['email'], 'uri' => $xmlConfig['m2m_communication_type']['url'], - 'login' => $xmlConfig['m2m_login'][0] ?? null + 'login' => $xmlConfig['m2m_login'][0] ?? null, + 'passwordAlreadyExists' => !empty($xmlConfig['m2m_password']) ? true : false ] ]; diff --git a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html index 3dd88e9df93..6c45261832f 100644 --- a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html +++ b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html @@ -1,6 +1,7 @@ <ng-container *ngIf="!loading; else elseTemplate"> <app-maarch-message [content]="'lang.maarch2maarchDesc' | translate : {url : maarch2maarchUrl}"> </app-maarch-message> + <app-maarch-message *ngIf="!passwordAlreadyExists" [mode]="'danger'" [content]="'lang.m2mPasswordMsg' | translate"></app-maarch-message> <div class="formType" style="margin-top: 20px;"> <div class="formType-title"> {{('lang.communicationMeans' | translate)}} diff --git a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts index 41a9953000f..63a314e034f 100644 --- a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts +++ b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts @@ -40,7 +40,7 @@ export class MaarchToMaarchParametersComponent implements OnInit { communications = { uri: new FormControl('https://demo.maarchcourrier.com'), login: new FormControl('cchaplin'), - password: new FormControl('maarch'), + password: new FormControl(null), email: new FormControl(null), }; annuary = { @@ -58,6 +58,8 @@ export class MaarchToMaarchParametersComponent implements OnInit { }; maarch2maarchUrl: string = `https://docs.maarch.org/gitbook/html/MaarchCourrier/${environment.VERSION.split('.')[0] + '.' + environment.VERSION.split('.')[1]}/guat/guat_exploitation/maarch2maarch.html`; + passwordAlreadyExists: boolean = false; + constructor( public translate: TranslateService, public http: HttpClient, @@ -195,8 +197,9 @@ export class MaarchToMaarchParametersComponent implements OnInit { this.http.get('../rest/m2m/configuration').pipe( map((data: any) => data.configuration), tap((data: any) => { - Object.keys(this.communications).forEach(elemId => { - if (!this.functionsService.empty(data.communications[elemId])) { + this.passwordAlreadyExists = data.communications.passwordAlreadyExists ? true : false; + Object.keys(this.communications).forEach((elemId: any) => { + if (['uri', 'login', 'email'].indexOf(elemId) > -1) { this.communications[elemId].setValue(data.communications[elemId]); } this.communications[elemId].valueChanges @@ -362,6 +365,7 @@ export class MaarchToMaarchParametersComponent implements OnInit { this.http.put('../rest/m2m/configuration', { configuration: this.formatConfiguration() }).pipe( tap(() => { this.notify.success(this.translate.instant('lang.dataUpdated')); + this.passwordAlreadyExists = this.functionsService.empty(this.communications['password'].value) ? false : true; }), catchError((err: any) => { this.notify.handleErrors(err); diff --git a/src/lang/lang-en.json b/src/lang/lang-en.json index 818133efb6e..23d6112e3d4 100644 --- a/src/lang/lang-en.json +++ b/src/lang/lang-en.json @@ -2559,5 +2559,7 @@ "userIdMaarch2Maarch": "User identifier", "userPasswordMaarch2Maarch": "User password", "userIdMaarch2MaarchDesc": "User ID with a web service account", - "userPasswordMaarch2MaarchDesc": "User password with a web service account" + "userPasswordMaarch2MaarchDesc": "User password with a web service account", + "m2mPasswordMsg": "The password for your <b>web service user</b> is not defined" + } diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index e4f18b274c4..f677ebb6dfe 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2549,5 +2549,6 @@ "userIdMaarch2Maarch": "Identifiant de l'utilisateur", "userPasswordMaarch2Maarch": "Mot de passe de l'utilisateur", "userIdMaarch2MaarchDesc": "Identifiant de l'utilisateur avec un compte webservice", - "userPasswordMaarch2MaarchDesc": "Mot de passe de l'utilisateur avec un compte webservice" + "userPasswordMaarch2MaarchDesc": "Mot de passe de l'utilisateur avec un compte webservice", + "m2mPasswordMsg": "Le mot de passe de votre <b>utilisateur webservice</b> n'est pas défini" } -- GitLab