From 0f62f07cf212a45c1643502cde88381cb5864e68 Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:08:11 -0700 Subject: [PATCH] add clarifying comment to handleAuthResult() --- libs/auth/src/angular/login/login.component.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index c3d992144d..25fb249586 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -126,6 +126,10 @@ export class LoginComponentV2 implements OnInit, OnDestroy { await this.validateEmail(); } } + + if (this.clientType === ClientType.Desktop) { + await this.desktopOnInit(); + } } ngOnDestroy(): void { @@ -171,6 +175,14 @@ export class LoginComponentV2 implements OnInit, OnDestroy { 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 { if (this.handleCaptchaRequired(authResult)) { this.captchaSiteKey = authResult.captchaSiteKey; @@ -208,6 +220,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { // ...on Web if (this.clientType === ClientType.Web) { await this.goAfterLogIn(authResult.userId); + return; // ...on Browser/Desktop } else { @@ -219,6 +232,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { } else { await this.router.navigate(["vault"]); // Desktop } + return; } } @@ -460,4 +474,8 @@ export class LoginComponentV2 implements OnInit, OnDestroy { this.showResetPasswordAutoEnrollWarning = orgPolicies?.isPolicyAndAutoEnrollEnabled; this.enforcedPasswordPolicyOptions = orgPolicies?.enforcedPasswordPolicyOptions; } + + private async desktopOnInit(): Promise { + await this.getLoginWithDevice(this.loggedEmail); + } }