1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-15 01:11:47 +01:00

add clarifying comment to handleAuthResult()

This commit is contained in:
rr-bw 2024-09-11 10:08:11 -07:00
parent 04ca09145b
commit 0f62f07cf2
No known key found for this signature in database
GPG Key ID: 3FA13C3ADEE51D5D

View File

@ -126,6 +126,10 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
await this.validateEmail(); await this.validateEmail();
} }
} }
if (this.clientType === ClientType.Desktop) {
await this.desktopOnInit();
}
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -171,6 +175,14 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
await this.handleAuthResult(authResult); await this.handleAuthResult(authResult);
}; };
/**
* Handles the result of the authentication process.
*
* @param authResult
* @returns A simple `return` statement for each conditional check.
* If you update this method, do not forget to add a `return`
* to each if-condition block where necessary to stop code execution.
*/
private async handleAuthResult(authResult: AuthResult): Promise<void> { private async handleAuthResult(authResult: AuthResult): Promise<void> {
if (this.handleCaptchaRequired(authResult)) { if (this.handleCaptchaRequired(authResult)) {
this.captchaSiteKey = authResult.captchaSiteKey; this.captchaSiteKey = authResult.captchaSiteKey;
@ -208,6 +220,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
// ...on Web // ...on Web
if (this.clientType === ClientType.Web) { if (this.clientType === ClientType.Web) {
await this.goAfterLogIn(authResult.userId); await this.goAfterLogIn(authResult.userId);
return;
// ...on Browser/Desktop // ...on Browser/Desktop
} else { } else {
@ -219,6 +232,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
} else { } else {
await this.router.navigate(["vault"]); // Desktop await this.router.navigate(["vault"]); // Desktop
} }
return;
} }
} }
@ -460,4 +474,8 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
this.showResetPasswordAutoEnrollWarning = orgPolicies?.isPolicyAndAutoEnrollEnabled; this.showResetPasswordAutoEnrollWarning = orgPolicies?.isPolicyAndAutoEnrollEnabled;
this.enforcedPasswordPolicyOptions = orgPolicies?.enforcedPasswordPolicyOptions; this.enforcedPasswordPolicyOptions = orgPolicies?.enforcedPasswordPolicyOptions;
} }
private async desktopOnInit(): Promise<void> {
await this.getLoginWithDevice(this.loggedEmail);
}
} }