WEB-233: Improve the OIDC integration with 2FA (#2602)
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<div class="container m-b-20 layout-row layout-lt-md-column align-end gap-2percent">
|
||||
<button mat-raised-button color="primary" [routerLink]="['edit']">
|
||||
<fa-icon icon="edit" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Edit' | translate }}
|
||||
</button>
|
||||
<button mat-raised-button color="warn" (click)="delete()">
|
||||
<fa-icon icon="trash" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Delete' | translate }}
|
||||
</button>
|
||||
<div
|
||||
*ngIf="userData.isSelfServiceUser === 'USER_STATE_ACTIVE' || userData.isSelfServiceUser === 'USER_STATE_INACTIVE'"
|
||||
>
|
||||
<button mat-raised-button color="primary" (click)="changeUserPassword(userData.id)">
|
||||
<fa-icon icon="cog" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Change Password' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
<div [ngSwitch]="userData.isSelfServiceUser">
|
||||
<button *ngSwitchCase="'USER_STATE_ACTIVE'" mat-raised-button color="warn" (click)="desactiveUser(userData.id)">
|
||||
<fa-icon icon="ban" class="m-r-10"></fa-icon>
|
||||
Desactivar
|
||||
</button>
|
||||
<button *ngSwitchCase="'USER_STATE_INACTIVE'" mat-raised-button color="primary" (click)="activeUser(userData.id)">
|
||||
<fa-icon icon="check" class="m-r-10"></fa-icon>
|
||||
Activar
|
||||
</button>
|
||||
<button *ngSwitchDefault mat-raised-button color="primary" disabled>
|
||||
<fa-icon icon="ban" class="m-r-10"></fa-icon>
|
||||
Initial
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<div class="layout-row-wrap">
|
||||
<div class="flex-50 mat-body-strong">
|
||||
{{ 'labels.inputs.Login Name' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ userData.username }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
{{ 'labels.inputs.First Name' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ userData.firstname }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
{{ 'labels.inputs.Last Name' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ userData.lastname }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong" *ngIf="userData.email">
|
||||
{{ 'labels.inputs.Email' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50" *ngIf="userData.email">
|
||||
{{ userData.email }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
{{ 'labels.inputs.Office' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ userData.officeName }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
{{ 'labels.inputs.Roles' | translate }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
<span *ngFor="let role of userData.selectedRoles">
|
||||
{{ role.name }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-row layout-align-center gap-2percent column-on-mobile">
|
||||
<button type="button" mat-raised-button color="primary" [routerLink]="['../../']">
|
||||
{{ 'labels.buttons.Back' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
|
||||
.content {
|
||||
div {
|
||||
margin: 1rem 0;
|
||||
word-wrap: break-word;
|
||||
|
||||
span {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ViewUserComponent as ViewUserZitadelComponent } from './view-user.component';
|
||||
|
||||
describe('ViewUserComponent', () => {
|
||||
let component: ViewUserZitadelComponent;
|
||||
let fixture: ComponentFixture<ViewUserZitadelComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ViewUserZitadelComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ViewUserZitadelComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,113 @@
|
||||
/** Angular Imports */
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
/** Custom Services */
|
||||
//import { UsersService } from '../users.service';
|
||||
import { UsersServiceZitadel } from '../usersZitadel.service';
|
||||
|
||||
/** aUTH zITADEL */
|
||||
import { AuthService } from 'app/zitadel/auth.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { ChangePasswordDialogComponent } from 'app/zitadel/shared/change-password-dialog/change-password-dialog.component';
|
||||
import { strings } from '@angular-devkit/schematics';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
|
||||
/**
|
||||
* View user component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-view-user',
|
||||
templateUrl: './view-user.component.html',
|
||||
styleUrls: ['./view-user.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
FontAwesomeModule
|
||||
]
|
||||
})
|
||||
export class ViewUserComponent {
|
||||
/** User Data. */
|
||||
userData: any;
|
||||
|
||||
/**
|
||||
* Retrieves the user data from `resolve`.
|
||||
* @param {UsersServiceZitadel} usersServiceZitadel Users Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
*/
|
||||
constructor(
|
||||
private usersService: UsersServiceZitadel,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private authService: AuthService
|
||||
) {
|
||||
this.route.data.subscribe((data: { user: any }) => {
|
||||
const u = data.user.object?.result?.[0];
|
||||
|
||||
const user = {
|
||||
id: u.id,
|
||||
username: u.userName,
|
||||
firstname: u.human?.profile?.firstName,
|
||||
lastname: u.human?.profile?.lastName,
|
||||
officeName: 'Head Office',
|
||||
officeId: u.user_uuid ?? null,
|
||||
availableRoles: u.availableRoles ?? 'Admin',
|
||||
selectedRoles: u.selectedRoles ?? 'Admin',
|
||||
isSelfServiceUser: u.state
|
||||
};
|
||||
|
||||
this.userData = user;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the user and redirects to users.
|
||||
*/
|
||||
delete() {
|
||||
const deleteUserDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `user ${this.userData.id}` }
|
||||
});
|
||||
|
||||
deleteUserDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.authService.deletUser(this.userData.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Password of the Users.
|
||||
*/
|
||||
changeUserPassword(userId: string) {
|
||||
const changeUserPasswordDialogRef = this.dialog.open(ChangePasswordDialogComponent, {
|
||||
width: '440px',
|
||||
data: { id: userId }
|
||||
});
|
||||
changeUserPasswordDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.password && response.repeatPassword) {
|
||||
const password = response.password;
|
||||
const repeatPassword = response.repeatPassword;
|
||||
const firstname = this.userData.firstname;
|
||||
const data = { password: password, repeatPassword: repeatPassword, firstname: firstname };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* disable User
|
||||
*/
|
||||
|
||||
desactiveUser(userId: string) {
|
||||
this.authService.desactiveUser(userId);
|
||||
}
|
||||
|
||||
activeUser(userId: string) {
|
||||
this.authService.activeUser(userId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user