From 960ece29031ac017d44f41afb37d1cdcc0a2049d Mon Sep 17 00:00:00 2001 From: Thomas Avery Date: Tue, 26 Nov 2024 15:50:41 -0600 Subject: [PATCH] add loginSuccessHandlerService to BaseLoginViaWebAuthnComponent --- .../base-login-via-webauthn.component.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/angular/src/auth/components/base-login-via-webauthn.component.ts b/libs/angular/src/auth/components/base-login-via-webauthn.component.ts index c2bd1becf2..3396169dc8 100644 --- a/libs/angular/src/auth/components/base-login-via-webauthn.component.ts +++ b/libs/angular/src/auth/components/base-login-via-webauthn.component.ts @@ -1,6 +1,7 @@ import { Directive, OnInit } from "@angular/core"; import { Router } from "@angular/router"; +import { LoginSuccessHandlerService } from "@bitwarden/auth/common"; import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction"; import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason"; import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view"; @@ -24,6 +25,7 @@ export class BaseLoginViaWebAuthnComponent implements OnInit { private logService: LogService, private validationService: ValidationService, private i18nService: I18nService, + private loginSuccessHandlerService: LoginSuccessHandlerService, ) {} ngOnInit(): void { @@ -57,11 +59,17 @@ export class BaseLoginViaWebAuthnComponent implements OnInit { this.i18nService.t("twoFactorForPasskeysNotSupportedOnClientUpdateToLogIn"), ); this.currentState = "assertFailed"; - } else if (authResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) { - await this.router.navigate([this.forcePasswordResetRoute]); - } else { - await this.router.navigate([this.successRoute]); + return; } + + await this.loginSuccessHandlerService.run(authResult.userId); + + if (authResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) { + await this.router.navigate([this.forcePasswordResetRoute]); + return; + } + + await this.router.navigate([this.successRoute]); } catch (error) { if (error instanceof ErrorResponse) { this.validationService.showError(this.i18nService.t("invalidPasskeyPleaseTryAgain"));