1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-12 19:50:46 +01:00

move sync to post login action

This commit is contained in:
Kyle Spearrin 2018-04-25 12:08:18 -04:00
parent 31bd1f9423
commit 05e6d2c0f0
2 changed files with 11 additions and 5 deletions

View File

@ -16,13 +16,14 @@ export class LoginComponent {
masterPassword: string = '';
showPassword: boolean = false;
formPromise: Promise<AuthResult>;
onSuccessfullLogin: () => Promise<any>;
protected twoFactorRoute = '2fa';
protected successRoute = 'vault';
constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2, protected toasterService: ToasterService,
protected i18nService: I18nService, protected syncService: SyncService) { }
protected i18nService: I18nService) { }
async submit() {
if (this.email == null || this.email === '') {
@ -48,7 +49,9 @@ export class LoginComponent {
this.analytics.eventTrack.next({ action: 'Logged In To Two-step' });
this.router.navigate([this.twoFactorRoute]);
} else {
this.syncService.fullSync(true);
if (this.onSuccessfullLogin != null) {
this.onSuccessfullLogin();
}
this.analytics.eventTrack.next({ action: 'Logged In' });
this.router.navigate([this.successRoute]);
}

View File

@ -37,6 +37,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
twoFactorEmail: string = null;
formPromise: Promise<any>;
emailPromise: Promise<any>;
onSuccessfullLogin: () => Promise<any>;
protected loginRoute = 'login';
protected successRoute = 'vault';
@ -44,8 +45,8 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2, protected toasterService: ToasterService,
protected i18nService: I18nService, protected apiService: ApiService,
protected platformUtilsService: PlatformUtilsService, protected syncService: SyncService,
protected win: Window, protected environmentService: EnvironmentService) {
protected platformUtilsService: PlatformUtilsService, protected win: Window,
protected environmentService: EnvironmentService) {
this.u2fSupported = this.platformUtilsService.supportsU2f(win);
}
@ -164,7 +165,9 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
try {
this.formPromise = this.authService.logInTwoFactor(this.selectedProviderType, this.token, this.remember);
await this.formPromise;
this.syncService.fullSync(true);
if (this.onSuccessfullLogin != null) {
this.onSuccessfullLogin();
}
this.analytics.eventTrack.next({ action: 'Logged In From Two-step' });
this.router.navigate([this.successRoute]);
} catch (e) {