mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-13 00:51:45 +01:00
refactor submit logic further to use if statements with returns instead of if...else if...else
This commit is contained in:
parent
feb16c3fd2
commit
d098ee0cbc
@ -184,17 +184,28 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
|
|||||||
message: this.i18nService.t("encryptionKeyMigrationRequired"),
|
message: this.i18nService.t("encryptionKeyMigrationRequired"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (authResult.requiresTwoFactor) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authResult.requiresTwoFactor) {
|
||||||
await this.router.navigate(["2fa"]);
|
await this.router.navigate(["2fa"]);
|
||||||
} else if (authResult.forcePasswordReset != ForceSetPasswordReason.None) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authResult.forcePasswordReset != ForceSetPasswordReason.None) {
|
||||||
this.loginEmailService.clearValues();
|
this.loginEmailService.clearValues();
|
||||||
await this.router.navigate(["update-temp-password"]);
|
await this.router.navigate(["update-temp-password"]);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If none of the above cases are true, proceed with login...
|
||||||
|
// ...on Web
|
||||||
if (this.clientType === ClientType.Web) {
|
if (this.clientType === ClientType.Web) {
|
||||||
await this.goAfterLogIn(authResult.userId);
|
await this.goAfterLogIn(authResult.userId);
|
||||||
|
|
||||||
|
// ...on Browser/Desktop
|
||||||
} else {
|
} else {
|
||||||
await this.syncService.fullSync(true); // TODO-rr-bw: browser used `await`, desktop used `return`. Why?
|
await this.syncService.fullSync(true); // TODO-rr-bw: browser used `await`, desktop used `return`. Why?
|
||||||
|
|
||||||
this.loginEmailService.clearValues();
|
this.loginEmailService.clearValues();
|
||||||
|
|
||||||
if (this.clientType === ClientType.Browser) {
|
if (this.clientType === ClientType.Browser) {
|
||||||
@ -203,7 +214,6 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
|
|||||||
await this.router.navigate(["vault"]); // Desktop
|
await this.router.navigate(["vault"]); // Desktop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected async goAfterLogIn(userId: UserId): Promise<void> {
|
protected async goAfterLogIn(userId: UserId): Promise<void> {
|
||||||
|
Loading…
Reference in New Issue
Block a user