Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
success callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Oct 15, 2018
1 parent 0d30a1a commit 2f6426d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/angular/components/hint.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class HintComponent {
formPromise: Promise<any>;

protected successRoute = 'login';
protected onSuccessfulSubmit: () => void;

constructor(protected router: Router, protected i18nService: I18nService,
protected apiService: ApiService, protected platformUtilsService: PlatformUtilsService) { }
Expand All @@ -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 { }
}
}
7 changes: 6 additions & 1 deletion src/angular/components/lock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'));
Expand Down

0 comments on commit 2f6426d

Please sign in to comment.