diff --git a/src/components/Authentication/Authenticator.tsx b/src/components/Authentication/Authenticator.tsx index 2a3499f..f5a1cfa 100644 --- a/src/components/Authentication/Authenticator.tsx +++ b/src/components/Authentication/Authenticator.tsx @@ -12,6 +12,13 @@ function useCodeAndError() { return [code, error]; } +function inferRedirectUrl() { + // Strip query parameters + const { protocol, host, pathname } = window.location; + const redirectUrl = `${protocol}//${host}${pathname}`; + return redirectUrl; +} + export default function Authenticator() { const { provider } = useParams<{ provider: string }>(); const [code, error] = useCodeAndError(); @@ -31,7 +38,7 @@ export default function Authenticator() { useEffect(() => { if (code) { setPending(true); - createSession(code) + createSession(code, inferRedirectUrl()) .then(({ token }) => { setToken(token ?? null); }) diff --git a/src/components/Authentication/createSession.ts b/src/components/Authentication/createSession.ts index 52fe274..7315d0e 100644 --- a/src/components/Authentication/createSession.ts +++ b/src/components/Authentication/createSession.ts @@ -1,7 +1,7 @@ -export async function createSession(code: string) { +export async function createSession(code: string, redirectUrl: string) { const res = await fetch('http://localhost:5000/create_session', { method: 'post', - body: JSON.stringify({ code }), + body: JSON.stringify({ code, redirectUrl }), headers: { 'Content-Type': 'application/json', }, diff --git a/src/components/Carpool.tsx b/src/components/Carpool.tsx index e86b054..ffce9dc 100644 --- a/src/components/Carpool.tsx +++ b/src/components/Carpool.tsx @@ -1,7 +1,7 @@ -import { ICarpool, IUser } from './types'; +import { ICarpool } from './types'; import UISecondaryBox from './UISecondaryBox'; -function MemberList({ members }: { members: IUser[] }) { +function MemberList({ members }: { members: ICarpool['members'] }) { return (