1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-12 00:41:29 +01:00

success callbacks

This commit is contained in:
Kyle Spearrin 2018-10-15 13:02:31 -04:00
parent 0d30a1a1c9
commit 2f6426deb4
2 changed files with 12 additions and 2 deletions

View File

@ -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 {
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 { }
}
}

View File

@ -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'));