diff --git a/server/routers/badger/exchangeSession.ts b/server/routers/badger/exchangeSession.ts index b8d01c11..4017cfea 100644 --- a/server/routers/badger/exchangeSession.ts +++ b/server/routers/badger/exchangeSession.ts @@ -62,7 +62,26 @@ export async function exchangeSession( cleanHost = cleanHost.slice(0, -1 * matched.length); } - const clientIp = requestIp?.split(":")[0]; + const clientIp = requestIp + ? (() => { + if (requestIp.startsWith("[") && requestIp.includes("]")) { + const ipv6Match = requestIp.match(/\[(.*?)\]/); + if (ipv6Match) { + return ipv6Match[1]; + } + } + + const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}/; + if (ipv4Pattern.test(requestIp)) { + const lastColonIndex = requestIp.lastIndexOf(":"); + if (lastColonIndex !== -1) { + return requestIp.substring(0, lastColonIndex); + } + } + + return requestIp; + })() + : undefined; const [resource] = await db .select() diff --git a/src/app/auth/org/page.tsx b/src/app/auth/org/page.tsx index add6439c..aee0ec40 100644 --- a/src/app/auth/org/page.tsx +++ b/src/app/auth/org/page.tsx @@ -87,8 +87,6 @@ export default async function OrgAuthPage(props: { redirect(env.app.dashboardUrl); } - console.log(user, forceLogin); - if (user && !forceLogin) { let redirectToken: string | undefined; try { diff --git a/src/components/OrgSelectionForm.tsx b/src/components/OrgSelectionForm.tsx index 51d84d36..c625008e 100644 --- a/src/components/OrgSelectionForm.tsx +++ b/src/components/OrgSelectionForm.tsx @@ -95,7 +95,7 @@ export function OrgSelectionForm() {
{t("orgAuthWhatsThis")}{" "}