Browse Source

success callbacks

pull/15/head
Kyle Spearrin 7 years ago
parent
commit
2f6426deb4
  1. 7
      src/angular/components/hint.component.ts
  2. 7
      src/angular/components/lock.component.ts

7
src/angular/components/hint.component.ts

@ -11,6 +11,7 @@ export class HintComponent { @@ -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) { }
@ -32,7 +33,11 @@ export class HintComponent { @@ -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
src/angular/components/lock.component.ts

@ -11,6 +11,7 @@ export class LockComponent { @@ -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 { @@ -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'));

Loading…
Cancel
Save