Commit 94e5057e authored by David Burke's avatar David Burke

Deactivate MFA implemented

parent 36eeb2aa
Pipeline #64246277 passed with stage
in 7 minutes and 28 seconds
......@@ -9,6 +9,9 @@ export enum ManageMfaActionTypes {
ACTIVATE_MFA = "[ENABLE MFA] Activate",
ACTIVATE_MFA_SUCCESS = "[ENABLE MFA] Activate Success",
ACTIVATE_MFA_FAILURE = "[ENABLE MFA] Activate Failure",
DEACTIVATE_MFA = "[ENABLE MFA] Deactivate",
DEACTIVATE_MFA_SUCCESS = "[ENABLE MFA] Deactivate Success",
DEACTIVATE_MFA_FAILURE = "[ENABLE MFA] Deactivate Failure",
RESET_FORM = "[Reset] = Reset Form"
}
......@@ -44,6 +47,18 @@ export class ActivateMfaFailure implements Action {
readonly type = ManageMfaActionTypes.ACTIVATE_MFA_FAILURE;
}
export class DeactivateMfa implements Action {
readonly type = ManageMfaActionTypes.DEACTIVATE_MFA;
}
export class DeactivateMfaSuccess implements Action {
readonly type = ManageMfaActionTypes.DEACTIVATE_MFA_SUCCESS;
}
export class DeactivateMfaFailure implements Action {
readonly type = ManageMfaActionTypes.DEACTIVATE_MFA_FAILURE;
}
export class ResetForm implements Action {
readonly type = ManageMfaActionTypes.RESET_FORM;
}
......@@ -56,4 +71,7 @@ export type ManageMfaActions =
| ActivateMfa
| ActivateMfaSuccess
| ActivateMfaFailure
| DeactivateMfa
| DeactivateMfaSuccess
| DeactivateMfaFailure
| ResetForm;
......@@ -35,13 +35,7 @@
<form *ngIf="mfaRequired" (sumbit)="disableMfa.emit()">
<div class="form-field form-field--large">
<app-form-label [isLarge]="true">
Password
</app-form-label>
<div class="form-field form-field--large">
<input type="password" class="form-field__input" />
</div>
<button class="button button--primary" (click)="disableMfa.emit()">
<button class="button button--primary" (click)="deactivateMfa.emit()">
Disable Two-Factor Authentication
</button>
</div>
......
......@@ -38,7 +38,7 @@ export class ManageMfaComponent {
@Output() generateMfa = new EventEmitter();
@Output() verifyMfa = new EventEmitter();
@Output() forwardStep = new EventEmitter();
@Output() disableMfa = new EventEmitter();
@Output() deactivateMfa = new EventEmitter();
constructor(private _sanitizer: DomSanitizer) {}
......
import { Component } from "@angular/core";
import { Store, select } from "@ngrx/store";
import { IState, getMfaRequired } from "../../app.reducers";
import { EnableMfa, ForwardStep, ActivateMfa } from "./manage-mfa.actions";
import {
EnableMfa,
ForwardStep,
ActivateMfa,
DeactivateMfa
} from "./manage-mfa.actions";
import {
getMfaProvisioningURI,
getMfaStep,
......@@ -20,6 +25,7 @@ import {
(forwardStep)="forwardStep()"
(generateMfa)="generateMfa()"
(verifyMfa)="activateMfa()"
(deactivateMfa)="deactivateMfa()"
></app-manage-mfa>
`
})
......@@ -42,4 +48,8 @@ export class ManageMfaContainer {
activateMfa() {
this.store.dispatch(new ActivateMfa());
}
deactivateMfa() {
this.store.dispatch(new DeactivateMfa());
}
}
......@@ -6,7 +6,9 @@ import {
EnableMfaSuccess,
EnableMfaFailure,
ActivateMfaFailure,
ActivateMfaSuccess
ActivateMfaSuccess,
DeactivateMfaSuccess,
DeactivateMfaFailure
} from "./manage-mfa.actions";
import { exhaustMap, map, catchError, withLatestFrom } from "rxjs/operators";
import { of } from "rxjs";
......@@ -45,6 +47,17 @@ export class ManageMFAEffects {
})
);
@Effect()
deactivateMfa$ = this.actions$.pipe(
ofType(ManageMfaActionTypes.DEACTIVATE_MFA),
exhaustMap(action =>
this.service.deactivateMfa().pipe(
map(resp => new DeactivateMfaSuccess()),
catchError(resp => of(new DeactivateMfaFailure()))
)
)
);
constructor(
private actions$: Actions,
private store: Store<IState>,
......
......@@ -446,6 +446,12 @@ export class UserService {
return this.http.post<null>(url, data);
}
/** Deactivate MFA, user will no longer need to enter MFA code to log in */
deactivateMfa() {
const url = this.sdk.formUrl("deactivate-mfa/");
return this.http.post<null>(url, null);
}
private setSdkUrl(url: string) {
this.store.dispatch(new SetUrlAction(url));
}
......
......@@ -127,6 +127,12 @@ export function authReducer(
mfaRequired: true
};
case ManageMfaActionTypes.DEACTIVATE_MFA_SUCCESS:
return {
...state,
mfaRequired: false
};
default:
return state;
}
......
Markdown is supported
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