From 9337b3c881e38fbf1ae8468f621b17df41912dfa Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 9 May 2023 18:20:26 -0400 Subject: [PATCH] fix(striker-ui-api): prefer original url over url/path of request --- striker-ui-api/src/lib/assertAuthentication.ts | 6 +++--- striker-ui-api/src/session.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/striker-ui-api/src/lib/assertAuthentication.ts b/striker-ui-api/src/lib/assertAuthentication.ts index e1a268f2..443dad37 100644 --- a/striker-ui-api/src/lib/assertAuthentication.ts +++ b/striker-ui-api/src/lib/assertAuthentication.ts @@ -29,7 +29,7 @@ export const assertAuthentication: AssertAuthenticationFunction = ({ let getReturnTo: ((...args: HandlerParameters) => string) | undefined; if (failReturnTo === true) { - getReturnTo = ({ path }) => path; + getReturnTo = ({ originalUrl, url }) => originalUrl || url; } else if (typeof failReturnTo === 'string') { getReturnTo = () => failReturnTo; } @@ -47,14 +47,14 @@ export const assertAuthentication: AssertAuthenticationFunction = ({ return (...args) => { const { 0: request } = args; - const { path, session } = request; + const { originalUrl, session } = request; const { passport } = session; if (passport?.user) return succeed(...args); const rt = getReturnTo?.call(null, ...args); - stdout(`Unauthenticated access to ${path}`); + stdout(`Unauthenticated access to ${originalUrl}`); if (rt) { stdout(`Set session.returnTo=${rt}`); diff --git a/striker-ui-api/src/session.ts b/striker-ui-api/src/session.ts index 00003e0c..309c84f8 100644 --- a/striker-ui-api/src/session.ts +++ b/striker-ui-api/src/session.ts @@ -187,10 +187,10 @@ export default (async () => maxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE, secure: false, }, - genid: ({ path }) => { + genid: ({ originalUrl }) => { const sid = uuid(); - stdout(`Generated session identifier ${sid}; request.path=${path}`); + stdout(`Generated session identifier ${sid}; access to ${originalUrl}`); return sid; },