Commit bf76689c authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #17117 TIME 0:45 Cannot create user in administration

parent 418f1346
...@@ -926,27 +926,26 @@ export class UserAdministrationComponent implements OnInit { ...@@ -926,27 +926,26 @@ export class UserAdministrationComponent implements OnInit {
if (this.creationMode) { if (this.creationMode) {
this.http.get('../rest/users/' + this.user.userId + '/status') this.http.get('../rest/users/' + this.user.userId + '/status')
.subscribe((data: any) => { .subscribe((data: any) => {
let deletedUser = false;
if (data.status && data.status === 'DEL') { if (data.status && data.status === 'DEL') {
const dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: `${this.translate.instant('lang.reactivateUserDeleted')}`, msg: this.translate.instant('lang.confirmAction') } }); const dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: `${this.translate.instant('lang.reactivateUserDeleted')}`, msg: this.translate.instant('lang.confirmAction') } });
dialogRef.afterClosed().pipe( dialogRef.afterClosed().pipe(
filter((response: string) => response === 'ok'), filter((response: string) => response === 'ok'),
exhaustMap(() => this.http.post('../rest/users', this.user)), exhaustMap(() => this.http.post('../rest/users', this.user)),
tap((result: any) => { tap((result: any) => {
if (deletedUser) { this.subscribeUserCreation(true, result.id);
this.notify.success(this.translate.instant('lang.userUpdated'));
} else {
this.notify.success(this.translate.instant('lang.userAdded'));
}
this.appInputCorrespondentGroup.linkGrpAfterCreation(result.id, 'user');
this.router.navigate(['/administration/users/' + result.id]);
}), }),
catchError((err: any) => { catchError((err: any) => {
this.notify.error(err.error.errors); this.notify.error(err.error.errors);
return of(false); return of(false);
}) })
).subscribe(); ).subscribe();
deletedUser = true; } else {
this.http.post('../rest/users', this.user)
.subscribe((result: any) => {
this.subscribeUserCreation(false, result.id);
}, (err: any) => {
this.notify.handleSoftErrors(err);
});
} }
}, (err: any) => { }, (err: any) => {
this.notify.error(err.error.errors); this.notify.error(err.error.errors);
...@@ -970,6 +969,16 @@ export class UserAdministrationComponent implements OnInit { ...@@ -970,6 +969,16 @@ export class UserAdministrationComponent implements OnInit {
} }
} }
subscribeUserCreation(deletedUser: boolean, userId: any) {
if (deletedUser) {
this.notify.success(this.translate.instant('lang.userUpdated'));
} else {
this.notify.success(this.translate.instant('lang.userAdded'));
}
this.appInputCorrespondentGroup.linkGrpAfterCreation(userId, 'user');
this.router.navigate(['/administration/users/' + userId]);
}
setUserModeLogin(event: any) { setUserModeLogin(event: any) {
if (event.checked) { if (event.checked) {
this.user.mode = 'rest'; this.user.mode = 'rest';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment