From 2cbc34a8a5894f6109e5f846fad8fb6295d014fb Mon Sep 17 00:00:00 2001 From: MytsV Date: Thu, 8 Aug 2024 16:10:03 +0300 Subject: [PATCH] Connect user switching with the frontend --- src/component-library/Pages/Layout/AccountDropdown.tsx | 2 +- src/pages/api/auth/switch.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/component-library/Pages/Layout/AccountDropdown.tsx b/src/component-library/Pages/Layout/AccountDropdown.tsx index 77c42fbec..06210fc33 100644 --- a/src/component-library/Pages/Layout/AccountDropdown.tsx +++ b/src/component-library/Pages/Layout/AccountDropdown.tsx @@ -16,7 +16,7 @@ const AccountList = (props: { accountList: string[] }) => { "text-right" )} key={index} - href="/api/account/switch" + href={`/api/auth/switch?account=${account}`} prefetch={false} > diff --git a/src/pages/api/auth/switch.ts b/src/pages/api/auth/switch.ts index c0fe71aae..3820ce852 100644 --- a/src/pages/api/auth/switch.ts +++ b/src/pages/api/auth/switch.ts @@ -25,7 +25,7 @@ async function switchUsers(req: NextApiRequest, res: NextApiResponse) { const user = session.allUsers?.at(userIdx!) await addOrUpdateSessionUser(session, user!, true) - res.redirect(callbackUrl as string ?? '/dashboard') + res.redirect(callbackUrl as string ?? '/') } export default withSessionRoute(switchUsers) \ No newline at end of file