fix: otp delete comfirmation (#729)

This commit is contained in:
Max Peintner 2020-09-11 13:52:07 +02:00 committed by GitHub
parent 4931000dc9
commit 15c977dab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
import { MatTable, MatTableDataSource } from '@angular/material/table'; import { MatTable, MatTableDataSource } from '@angular/material/table';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component';
import { MfaOtpResponse, MFAState, MfaType, MultiFactor } from 'src/app/proto/generated/auth_pb'; import { MfaOtpResponse, MFAState, MfaType, MultiFactor } from 'src/app/proto/generated/auth_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
@ -73,18 +74,32 @@ export class AuthUserMfaComponent implements OnInit, OnDestroy {
} }
public deleteMFA(type: MfaType): void { public deleteMFA(type: MfaType): void {
if (type === MfaType.MFATYPE_OTP) { const dialogRef = this.dialog.open(WarnDialogComponent, {
this.service.RemoveMfaOTP().then(() => { data: {
this.toast.showInfo('USER.TOAST.OTPREMOVED', true); confirmKey: 'ACTIONS.DELETE',
cancelKey: 'ACTIONS.CANCEL',
titleKey: 'USER.MFA.DIALOG.OTP_DELETE_TITLE',
descriptionKey: 'USER.MFA.DIALOG.OTP_DELETE_DESCRIPTION',
},
width: '400px',
});
const index = this.dataSource.data.findIndex(mfa => mfa.type === type); dialogRef.afterClosed().subscribe(resp => {
if (index > -1) { if (resp) {
this.dataSource.data.splice(index, 1); if (type === MfaType.MFATYPE_OTP) {
this.service.RemoveMfaOTP().then(() => {
this.toast.showInfo('USER.TOAST.OTPREMOVED', true);
const index = this.dataSource.data.findIndex(mfa => mfa.type === type);
if (index > -1) {
this.dataSource.data.splice(index, 1);
}
this.getOTP();
}).catch(error => {
this.toast.showError(error);
});
} }
}
}).catch(error => { });
this.toast.showError(error);
});
}
} }
} }

View File

@ -25,6 +25,7 @@ import { PasswordComplexityViewModule } from 'src/app/modules/password-complexit
import { RefreshTableModule } from 'src/app/modules/refresh-table/refresh-table.module'; import { RefreshTableModule } from 'src/app/modules/refresh-table/refresh-table.module';
import { SharedModule } from 'src/app/modules/shared/shared.module'; import { SharedModule } from 'src/app/modules/shared/shared.module';
import { UserGrantsModule } from 'src/app/modules/user-grants/user-grants.module'; import { UserGrantsModule } from 'src/app/modules/user-grants/user-grants.module';
import { WarnDialogModule } from 'src/app/modules/warn-dialog/warn-dialog.module';
import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe.module'; import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe.module';
import { LocalizedDatePipeModule } from 'src/app/pipes/localized-date-pipe.module'; import { LocalizedDatePipeModule } from 'src/app/pipes/localized-date-pipe.module';
import { TimestampToDatePipeModule } from 'src/app/pipes/timestamp-to-date-pipe.module'; import { TimestampToDatePipeModule } from 'src/app/pipes/timestamp-to-date-pipe.module';
@ -66,6 +67,7 @@ import { UserMfaComponent } from './user-detail/user-mfa/user-mfa.component';
ReactiveFormsModule, ReactiveFormsModule,
DetailFormModule, DetailFormModule,
DetailFormMachineModule, DetailFormMachineModule,
WarnDialogModule,
MatDialogModule, MatDialogModule,
QRCodeModule, QRCodeModule,
MetaLayoutModule, MetaLayoutModule,

View File

@ -108,6 +108,10 @@
"1": "Nicht bereit", "1": "Nicht bereit",
"2": "Bereit", "2": "Bereit",
"3": "Gelöscht" "3": "Gelöscht"
},
"DIALOG": {
"OTP_DELETE_TITLE":"OTP Faktor entfernen",
"OTP_DELETE_DESCRIPTION":"Sie sind im Begriff OTP als Zweitfaktormethode zu entfernen. Sind sie sicher?"
} }
}, },
"CREATE": { "CREATE": {

View File

@ -108,6 +108,10 @@
"1": "Not Ready", "1": "Not Ready",
"2": "Ready", "2": "Ready",
"3": "Deleted" "3": "Deleted"
},
"DIALOG": {
"OTP_DELETE_TITLE":"Remove OTP Factor",
"OTP_DELETE_DESCRIPTION":"You are about to delete OTP as second factor. Are you sure?"
} }
}, },
"CREATE": { "CREATE": {