From 2f6426deb470b71838b51c52587929ac64d428bf Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 15 Oct 2018 13:02:31 -0400 Subject: [PATCH] success callbacks --- src/angular/components/hint.component.ts | 7 ++++++- src/angular/components/lock.component.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/angular/components/hint.component.ts b/src/angular/components/hint.component.ts index e1052a58f4d..914ebfb95bd 100644 --- a/src/angular/components/hint.component.ts +++ b/src/angular/components/hint.component.ts @@ -11,6 +11,7 @@ export class HintComponent { formPromise: Promise; protected successRoute = 'login'; + protected onSuccessfulSubmit: () => void; constructor(protected router: Router, protected i18nService: I18nService, protected apiService: ApiService, protected platformUtilsService: PlatformUtilsService) { } @@ -32,7 +33,11 @@ export class HintComponent { await this.formPromise; this.platformUtilsService.eventTrack('Requested Hint'); this.platformUtilsService.showToast('success', null, this.i18nService.t('masterPassSent')); - this.router.navigate([this.successRoute]); + if (this.onSuccessfulSubmit != null) { + this.onSuccessfulSubmit(); + } else if (this.router != null) { + this.router.navigate([this.successRoute]); + } } catch { } } } diff --git a/src/angular/components/lock.component.ts b/src/angular/components/lock.component.ts index 1d2ba6f147d..6e8caea78a6 100644 --- a/src/angular/components/lock.component.ts +++ b/src/angular/components/lock.component.ts @@ -11,6 +11,7 @@ export class LockComponent { showPassword: boolean = false; protected successRoute: string = 'vault'; + protected onSuccessfulSubmit: () => void; constructor(protected router: Router, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService, @@ -33,7 +34,11 @@ export class LockComponent { if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { await this.cryptoService.setKey(key); this.messagingService.send('unlocked'); - this.router.navigate([this.successRoute]); + if (this.onSuccessfulSubmit != null) { + this.onSuccessfulSubmit(); + } else if (this.router != null) { + this.router.navigate([this.successRoute]); + } } else { this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), this.i18nService.t('invalidMasterPassword'));