feat: cancelable challenges
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user