mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-20 22:41:56 +00:00

* cli, core * material cdk * schematics * chore(deps): bump ngx-color from 7.3.3 to 8.0.2 in /console (#4228) Bumps [ngx-color](https://github.com/scttcper/ngx-color) from 7.3.3 to 8.0.2. - [Release notes](https://github.com/scttcper/ngx-color/releases) - [Commits](https://github.com/scttcper/ngx-color/compare/v7.3.3...v8.0.2) --- updated-dependencies: - dependency-name: ngx-color dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * eslint-plugin * chore(deps): bump moment from 2.29.3 to 2.29.4 in /console (#3926) Bumps [moment](https://github.com/moment/moment) from 2.29.3 to 2.29.4. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.29.3...2.29.4) --- updated-dependencies: - dependency-name: moment dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump codemirror from 5.65.6 to 6.0.1 in /console (#3928) Bumps [codemirror](https://github.com/codemirror/basic-setup) from 5.65.6 to 6.0.1. - [Release notes](https://github.com/codemirror/basic-setup/releases) - [Changelog](https://github.com/codemirror/basic-setup/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/basic-setup/commits/6.0.1) --- updated-dependencies: - dependency-name: codemirror dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * lock * use codemirror 5 * remove redundant null undefined checks * i18n, undefined checks * remove redundant null and undefined checks * checks * fix: resolve null check warnings * commonjs deps Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Livio Spring <livio.a@gmail.com>
130 lines
4.1 KiB
TypeScript
130 lines
4.1 KiB
TypeScript
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { MatSort } from '@angular/material/sort';
|
|
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component';
|
|
import { AuthFactor, AuthFactorState } from 'src/app/proto/generated/zitadel/user_pb';
|
|
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { AuthFactorDialogComponent } from '../auth-factor-dialog/auth-factor-dialog.component';
|
|
|
|
export interface WebAuthNOptions {
|
|
challenge: string;
|
|
rp: { name: string; id: string };
|
|
user: { name: string; id: string; displayName: string };
|
|
pubKeyCredParams: any;
|
|
authenticatorSelection: { userVerification: string };
|
|
timeout: number;
|
|
attestation: string;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'cnsl-auth-user-mfa',
|
|
templateUrl: './auth-user-mfa.component.html',
|
|
styleUrls: ['./auth-user-mfa.component.scss'],
|
|
})
|
|
export class AuthUserMfaComponent implements OnInit, OnDestroy {
|
|
public displayedColumns: string[] = ['name', 'type', 'state', 'actions'];
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
|
|
|
@ViewChild(MatTable) public table!: MatTable<AuthFactor.AsObject>;
|
|
@ViewChild(MatSort) public sort!: MatSort;
|
|
public dataSource: MatTableDataSource<AuthFactor.AsObject> = new MatTableDataSource<AuthFactor.AsObject>([]);
|
|
|
|
public AuthFactorState: any = AuthFactorState;
|
|
|
|
public error: string = '';
|
|
public otpAvailable: boolean = false;
|
|
|
|
constructor(private service: GrpcAuthService, private toast: ToastService, private dialog: MatDialog) {}
|
|
|
|
public ngOnInit(): void {
|
|
this.getMFAs();
|
|
}
|
|
|
|
public ngOnDestroy(): void {
|
|
this.loadingSubject.complete();
|
|
}
|
|
|
|
public addAuthFactor(): void {
|
|
const dialogRef = this.dialog.open(AuthFactorDialogComponent, {
|
|
data: {
|
|
otpDisabled: !this.otpAvailable,
|
|
},
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(() => {
|
|
this.getMFAs();
|
|
});
|
|
}
|
|
|
|
public getMFAs(): void {
|
|
this.service
|
|
.listMyMultiFactors()
|
|
.then((mfas) => {
|
|
const list = mfas.resultList;
|
|
this.dataSource = new MatTableDataSource(list);
|
|
this.dataSource.sort = this.sort;
|
|
|
|
const index = list.findIndex((mfa) => mfa.otp);
|
|
if (index === -1) {
|
|
this.otpAvailable = true;
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.error = error.message;
|
|
});
|
|
}
|
|
|
|
public deleteMFA(factor: AuthFactor.AsObject): void {
|
|
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
|
data: {
|
|
confirmKey: 'ACTIONS.DELETE',
|
|
cancelKey: 'ACTIONS.CANCEL',
|
|
titleKey: 'USER.MFA.DIALOG.MFA_DELETE_TITLE',
|
|
descriptionKey: 'USER.MFA.DIALOG.MFA_DELETE_DESCRIPTION',
|
|
},
|
|
width: '400px',
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe((resp) => {
|
|
if (resp) {
|
|
if (factor.otp) {
|
|
this.service
|
|
.removeMyMultiFactorOTP()
|
|
.then(() => {
|
|
this.toast.showInfo('USER.TOAST.OTPREMOVED', true);
|
|
|
|
const index = this.dataSource.data.findIndex((mfa) => !!mfa.otp);
|
|
if (index > -1) {
|
|
this.dataSource.data.splice(index, 1);
|
|
}
|
|
this.getMFAs();
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
} else if (factor.u2f) {
|
|
this.service
|
|
.removeMyMultiFactorU2F(factor.u2f.id)
|
|
.then(() => {
|
|
this.toast.showInfo('USER.TOAST.U2FREMOVED', true);
|
|
|
|
const index = this.dataSource.data.findIndex((mfa) => !!mfa.u2f);
|
|
if (index > -1) {
|
|
this.dataSource.data.splice(index, 1);
|
|
}
|
|
this.getMFAs();
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|