mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
refactor submit logic further to use if statements with returns instead of if...else if...else
This commit is contained in:
@@ -184,24 +184,34 @@ 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"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If none of the above cases are true, proceed with login...
|
||||||
|
// ...on Web
|
||||||
|
if (this.clientType === ClientType.Web) {
|
||||||
|
await this.goAfterLogIn(authResult.userId);
|
||||||
|
|
||||||
|
// ...on Browser/Desktop
|
||||||
} else {
|
} else {
|
||||||
if (this.clientType === ClientType.Web) {
|
await this.syncService.fullSync(true); // TODO-rr-bw: browser used `await`, desktop used `return`. Why?
|
||||||
await this.goAfterLogIn(authResult.userId);
|
this.loginEmailService.clearValues();
|
||||||
|
|
||||||
|
if (this.clientType === ClientType.Browser) {
|
||||||
|
await this.router.navigate(["/tabs/vault"]);
|
||||||
} else {
|
} else {
|
||||||
await this.syncService.fullSync(true); // TODO-rr-bw: browser used `await`, desktop used `return`. Why?
|
await this.router.navigate(["vault"]); // Desktop
|
||||||
|
|
||||||
this.loginEmailService.clearValues();
|
|
||||||
|
|
||||||
if (this.clientType === ClientType.Browser) {
|
|
||||||
await this.router.navigate(["/tabs/vault"]);
|
|
||||||
} else {
|
|
||||||
await this.router.navigate(["vault"]); // Desktop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user