From 9814e0e5795ebc087ae8718882b2a3521f2d6582 Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:40:16 -0700 Subject: [PATCH] handle both unauthed and authed flows --- apps/browser/src/_locales/en/messages.json | 3 ++ apps/desktop/src/locales/en/messages.json | 3 ++ apps/web/src/locales/en/messages.json | 3 ++ .../login-via-auth-request.component.ts | 32 ++++++++++++------- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index f8dde376b35..fc708ba9790 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -3657,6 +3657,9 @@ "thisRequestIsNoLongerValid": { "message": "This request is no longer valid." }, + "thatRequestIsNoLongerValidStartingNewRequest": { + "message": "That request is no longer valid. Starting a new request." + }, "loginRequestHasAlreadyExpired": { "message": "Login request has already expired." }, diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 72d40ed750f..e190ad8c5ae 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -3113,6 +3113,9 @@ "thisRequestIsNoLongerValid": { "message": "This request is no longer valid." }, + "thatRequestIsNoLongerValidStartingNewRequest": { + "message": "That request is no longer valid. Starting a new request." + }, "confirmAccessAttempt": { "message": "Confirm access attempt for $EMAIL$", "placeholders": { diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index bbd89c1d288..6928b8bfdff 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -3978,6 +3978,9 @@ "thisRequestIsNoLongerValid": { "message": "This request is no longer valid." }, + "thatRequestIsNoLongerValidStartingNewRequest": { + "message": "That request is no longer valid. Starting a new request." + }, "loginRequestApprovedForEmailOnDevice": { "message": "Login request approved for $EMAIL$ on $DEVICE$", "placeholders": { diff --git a/libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts b/libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts index f95af8573d0..5ccc221777a 100644 --- a/libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts +++ b/libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts @@ -562,13 +562,7 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy { ); } } catch (error) { - // If the request no longer exists, we treat it as if it's been answered (and denied). - if (error instanceof ErrorResponse && error.statusCode === HttpStatusCode.NotFound) { - authRequestResponse = undefined; - this.logService.error("Auth request response not generated"); - } else { - this.logService.error(error); - } + this.logService.error(error); this.loading = false; } @@ -589,6 +583,10 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy { // Request doesn't exist anymore, so we'll clear the cache and start a new request. if (!authRequestResponse) { + this.toastService.showToast({ + variant: "info", + message: this.i18nService.t("thatRequestIsNoLongerValidStartingNewRequest"), + }); return await this.clearExistingStandardAuthRequestAndStartNewRequest(); } @@ -639,11 +637,21 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy { return; } - await this.decryptViaApprovedAuthRequest( - authRequestResponse, - this.authRequestKeyPair.privateKey, - userId, - ); + try { + await this.decryptViaApprovedAuthRequest( + authRequestResponse, + this.authRequestKeyPair.privateKey, + userId, + ); + } catch (error) { + this.logService.error(error); + this.toastService.showToast({ + variant: "info", + message: this.i18nService.t("thatRequestIsNoLongerValidStartingNewRequest"), + }); + await this.clearExistingStandardAuthRequestAndStartNewRequest(); + this.loading = false; + } } private async handleUnauthenticatedFlows(