Skip to content

Commit

Permalink
refactor: Minor enrollment class improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
atomrc committed Jan 18, 2024
1 parent f66f195 commit 04c952d
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/script/E2EIdentity/E2EIdentityEnrollment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class E2EIHandler extends TypedEventEmitter<Events> {

// If the silent authentication fails, clear the oidc service progress/data and renew manually
await this.cleanUp(true);
this.startEnrollment(ModalType.CERTIFICATE_RENEWAL);
await this.startEnrollment(ModalType.CERTIFICATE_RENEWAL);
}
}

Expand Down Expand Up @@ -387,17 +387,12 @@ export class E2EIHandler extends TypedEventEmitter<Events> {
});
}

private shouldShowNotification(): boolean {
// If the user has already snoozed the notification, don't show it again until the snooze period has expired
if (this.currentStep === E2EIHandlerStep.SNOOZE) {
return false;
}
return true;
}

private async showEnrollmentModal(modalType: ModalType.ENROLL | ModalType.CERTIFICATE_RENEWAL): Promise<void> {
private async showEnrollmentModal(
modalType: ModalType.ENROLL | ModalType.CERTIFICATE_RENEWAL,
config: EnrollmentConfig,
): Promise<void> {
// Show the modal with the provided modal type
const disableSnooze = await shouldEnableSoftLock(this.config!);
const disableSnooze = await shouldEnableSoftLock(config);
return new Promise<void>(resolve => {
const {modalOptions, modalType: determinedModalType} = getModalOptions({
hideSecondary: disableSnooze,
Expand Down Expand Up @@ -437,14 +432,14 @@ export class E2EIHandler extends TypedEventEmitter<Events> {
return this.enroll();
}

// Early return if we shouldn't show the notification
if (!this.shouldShowNotification()) {
if (this.config?.timer.isSnoozableTimerActive()) {
// If the user has snoozed, no need to show the notification modal
return;
}

// If the timer is not active, show the notification modal
if (this.config && !this.config.timer.isSnoozableTimerActive()) {
return this.showEnrollmentModal(enrollmentType);
if (this.config) {
return this.showEnrollmentModal(enrollmentType, this.config);
}
}
}

0 comments on commit 04c952d

Please sign in to comment.