feat: cancelable challenges

This commit is contained in:
Mo Bitar
2020-09-28 09:26:28 -05:00
parent ddbf50ee82
commit 3057eaafb4
7 changed files with 12 additions and 35 deletions

View File

@@ -33,9 +33,9 @@
ng-disabled="ctrl.state.processing"
)
.sk-label {{ctrl.state.processing ? 'Generating Keys...' : 'Submit'}}
.sk-panel-row(ng-if="ctrl.cancelable")
.sk-panel-row(ng-if="ctrl.challenge.cancelable")
a.sk-panel-row.sk-a.info.centered(
ng-if="ctrl.cancelable"
ng-if="ctrl.challenge.cancelable"
ng-click="ctrl.cancel()"
) Cancel

View File

@@ -36,7 +36,6 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
private $element: JQLite
application!: WebApplication
challenge!: Challenge
private cancelable = false
/* @ngInject */
constructor(
@@ -62,26 +61,10 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
invalid: false
};
}
let showForgotPasscodeLink = false;
switch (this.challenge.reason) {
case ChallengeReason.ApplicationUnlock:
showForgotPasscodeLink = true;
this.cancelable = false;
break;
case ChallengeReason.Migration:
showForgotPasscodeLink = true;
this.cancelable = false;
break;
case ChallengeReason.ProtocolUpgrade:
showForgotPasscodeLink = false;
this.cancelable = true;
break;
case ChallengeReason.ResaveRootKey:
showForgotPasscodeLink = false;
this.cancelable = true;
break;
}
this.cancelable = !showForgotPasscodeLink
const showForgotPasscodeLink = [
ChallengeReason.ApplicationUnlock,
ChallengeReason.Migration
].includes(this.challenge.reason);
this.setState({
prompts,
values,
@@ -143,7 +126,7 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
/** @template */
cancel() {
if (this.cancelable) {
if (this.challenge.cancelable) {
this.application!.cancelChallenge(this.challenge);
}
}