Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Minor enrollment class improvements #16545

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Comment on lines -390 to -396
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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);
}
}
}
Loading