From 87ba05a8f16e964c8e5260c5b709425d762b3d1b Mon Sep 17 00:00:00 2001 From: Chika Date: Wed, 30 Nov 2022 19:04:03 +0300 Subject: [PATCH] aps/api: fix getTargetUri --- apps/api/src/auth/auth.controller.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/src/auth/auth.controller.ts b/apps/api/src/auth/auth.controller.ts index 1b55052..feba045 100644 --- a/apps/api/src/auth/auth.controller.ts +++ b/apps/api/src/auth/auth.controller.ts @@ -28,9 +28,14 @@ export class AuthController { private getTargetUri(req) { const refererURL = new URL(req?.headers?.referer); - const targetUri = refererURL.searchParams.get('uri') || '/'; - return targetUri; + const targetUrl = refererURL.searchParams.get('uri') || refererURL.pathname; + + if (!targetUrl || targetUrl.includes('/login')) { + return '/'; + } + + return targetUrl; } private getInvalidPasswordUrl(targetUri: string) {