Skip to content
Snippets Groups Projects
Commit a32b348d authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #17109 TIME 7 convert internal user to otp

parent 6df1c3a2
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,11 @@
<!-- <mode>
<id>eidas</id>
<color>#00FF00</color>
</mode>
<mode>
<id>external</id>
<color>#FF0000</color>
<issuer></issuer>
</mode> -->
</signatureModes>
</ROOT>
......@@ -519,6 +519,10 @@
"noConnector": "Le connecteur associé n'existe pas",
"otpVisaUser": "L'utilisateur sera notifié par <b>courriel</b> au moment de son tour dans le circuit.",
"messageSaved": "Message enregistré",
"manage_customizationAdmin": "Personnaliser la page de connexion"
"manage_customizationAdmin": "Personnaliser la page de connexion",
"internalUserOtpMsg": "<b>{{user}}</b> sera converti en utilisateur externe, vous ne pourrez plus choisir les autres modes de signature.",
"externalUser": "Role externe",
"visa_yousignUser": "Viseur (Yousign)",
"sign_yousignUser": "Signataire (Yousign)"
}
}
......@@ -9,6 +9,11 @@
</ion-toolbar>
</ion-header>
<ion-content *ngIf="!loading">
<ion-card *ngIf="data?.type === undefined">
<ion-item color="primary">
<ion-label class="info" [innerHTML]="'lang.internalUserOtpMsg' | translate : { user : data.firstname + ' ' + data.lastname}"></ion-label>
</ion-item>
</ion-card>
<ion-card *ngIf="sources.length > 1">
<ion-item>
<ion-label color="secondary">{{'lang.source' | translate}}</ion-label>
......
......@@ -46,8 +46,16 @@ export class OtpCreateComponent implements OnInit {
this.http.get('../rest/connectors').pipe(
tap((data: any) => {
this.sources = data.otp;
this.currentSource = this.data ? this.data : this.sources[0];
this.connectorId = this.data ? this.currentSource.sourceId : this.currentSource.id;
if (this.data?.type === undefined) {
this.currentSource = this.sources[0];
this.connectorId = this.currentSource.id;
} else {
this.currentSource = {
sourceId : this.data.sourceId,
type: this.data.type
};
this.connectorId = this.currentSource.sourceId;
}
this.loading = false;
resolve(true);
}),
......
......@@ -20,7 +20,7 @@ export class OtpYousignComponent implements OnInit {
securityModes: any[] = [];
roles: any[] = ['visa', 'sign'];
roles: any[] = ['visa_yousign', 'sign_yousign'];
otp: any = {
type: 'yousign',
......@@ -29,7 +29,7 @@ export class OtpYousignComponent implements OnInit {
email: '',
phone: '',
security: 'sms',
role: 'visa',
role: 'sign_yousign',
sourceId: '',
modes: this.roles
};
......@@ -55,12 +55,15 @@ export class OtpYousignComponent implements OnInit {
getConfig() {
return new Promise((resolve) => {
this.http.get('../rest/connectors/' + this.otp.sourceId).pipe(
this.http.get('../rest/connectors/' + this.connectorId).pipe(
tap((data: any) => {
this.securityModes = [... new Set(data.otp.securityModes)];
this.otp.security = this.securityModes[0];
if (this.otpYousign) {
this.otp = this.otpYousign;
this.otp = {...this.otp, ...this.otpYousign};
this.otp.modes = this.roles;
this.otp.sourceId = this.connectorId;
this.formatPhone();
}
resolve(true);
}),
......
......@@ -80,7 +80,7 @@
<h2 [title]="diffusion.userDisplay" class="danger" *ngIf="diffusion.userDisplay === ''">
{{'lang.userDeleted' | translate}}</h2>
<p *ngIf="diffusion.noConnector === undefined && diffusion.processDate === null" style="display: flex;justify-content: start;">
<ion-select [(ngModel)]="diffusion.role" [title]="diffusion.userDisplay"
<ion-select [(ngModel)]="diffusion.role" (ionChange)="checkRole(diffusion, i, $event.detail.value)" [title]="diffusion.userDisplay"
interface="popover" [interfaceOptions]="customPopoverOptions"
[style.color]="getRole(diffusion.role)?.color" [disabled]="!editMode"
style="width: auto;max-width: 100%;padding-left:0px;">
......@@ -110,7 +110,7 @@
</ion-icon>
<ion-buttons slot="end">
<ion-button style="z-index: 9999" *ngIf="editMode && diffusion.userId === null && hasConnector" fill="clear" slot="icon-only" shape="round"
color="primary" (click)="$event.stopPropagation(); openOtpModal(diffusion)" [title]="'lang.updateOtp' | translate">
color="primary" (click)="$event.stopPropagation();openOtpModal(diffusion, i)" [title]="'lang.updateOtp' | translate">
<ion-icon name="create-outline"></ion-icon>
</ion-button>
<ion-button style="z-index: 9999" *ngIf="editMode" fill="clear" slot="icon-only" shape="round"
......
......@@ -159,13 +159,16 @@ export class VisaWorkflowComponent implements OnInit {
this.visaUsersList = [];
}
async openOtpModal(item: any = null) {
if (this.editMode && (item === null || (item && item.userId === null))) {
async openOtpModal(item: any = null, position: number = null, userId: number = null) {
if (this.editMode) {
let objToSend: any;
if (item === null || (item && item.userId !== null)) {
if (userId !== null) {
objToSend = await this.getUserInfo(userId);
} else if (item === null) {
objToSend = null;
} else {
if (item.userId === null && item.hasOwnProperty('status')) {
if (item.hasOwnProperty('status')) {
item = await this.formatData(item);
}
objToSend = {
......@@ -192,7 +195,10 @@ export class VisaWorkflowComponent implements OnInit {
modal.onDidDismiss()
.then(async (result: any) => {
if (typeof result.data === 'object') {
console.log(result);
if (result.data === 'cancel' && userId !== null) {
this.visaWorkflow[position].role = 'visa';
} else if (typeof result.data === 'object') {
const obj: any = {
'userId': null,
'userDisplay': `${result.data.firstname} ${result.data.lastname}`,
......@@ -203,8 +209,8 @@ export class VisaWorkflowComponent implements OnInit {
'modes': result.data.modes,
'otp': result.data
};
if (objToSend !== null) {
this.visaWorkflow[this.visaWorkflow.indexOf(item)] = obj;
if (position !== null && item !== null) {
this.visaWorkflow[position] = obj;
this.notificationService.success(this.translate.instant('lang.modificationSaved'));
} else {
this.visaWorkflow.push(obj);
......@@ -214,6 +220,27 @@ export class VisaWorkflowComponent implements OnInit {
}
}
getUserInfo(userId: number) {
return new Promise((resolve) => {
this.http.get(`../rest/users/${userId}`).pipe(
tap((data: any) => {
resolve({
firstname: data.user.firstname,
lastname: data.user.lastname,
email: data.user.email,
phone: data.user.phone,
modes: []
});
}),
catchError(err => {
this.notificationService.handleErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
}
getCurrentWorkflow() {
return this.visaWorkflow;
}
......@@ -273,7 +300,7 @@ export class VisaWorkflowComponent implements OnInit {
this.http.get('../rest/connectors').pipe(
tap((data: any) => {
this.hasConnector = data.otp.length > 0 ? true : false;
const connectorIds: any[] = data.otp.map((connector: any) => connector.id)
const connectorIds: any[] = data.otp.map((connector: any) => connector.id);
resolve(connectorIds);
}),
catchError(err => {
......@@ -331,13 +358,19 @@ export class VisaWorkflowComponent implements OnInit {
if (connectorIds.indexOf(objToSend.otp.sourceId) === -1) {
objToSend.otp.sourceId = connectorIds[0];
objToSend = {
... objToSend,
...objToSend,
noConnector: true
}
};
}
this.visaWorkflow[this.visaWorkflow.indexOf(item)] = objToSend;
resolve(objToSend);
});
}
}
checkRole(item: any, position: number, mode: string) {
if (mode === 'external') {
this.openOtpModal(item, position, item.userId);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment