diff --git a/apps/cyberstorm-remix/app/commonComponents/Navigation/Navigation.tsx b/apps/cyberstorm-remix/app/commonComponents/Navigation/Navigation.tsx index 4d274cf0e..a2f82ee0f 100644 --- a/apps/cyberstorm-remix/app/commonComponents/Navigation/Navigation.tsx +++ b/apps/cyberstorm-remix/app/commonComponents/Navigation/Navigation.tsx @@ -35,7 +35,10 @@ import { import { faDiscord, faGithub } from "@fortawesome/free-brands-svg-icons"; import { classnames } from "@thunderstore/cyberstorm/src/utils/utils"; -import { buildAuthLoginUrl } from "cyberstorm/utils/ThunderstoreAuth"; +import { + buildAuthLoginUrl, + buildLogoutUrl, +} from "cyberstorm/utils/ThunderstoreAuth"; import { faArrowUpRight } from "@fortawesome/pro-solid-svg-icons"; import { getPublicEnvVariables } from "cyberstorm/security/publicEnvVariables"; @@ -404,7 +407,7 @@ export function DesktopUserDropdown(props: { @@ -566,7 +569,7 @@ export function MobileUserPopoverContent(props: { diff --git a/apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx b/apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx index 3e47bdfe1..0343352ca 100644 --- a/apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx +++ b/apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx @@ -1,14 +1,23 @@ -interface Props { +import { getPublicEnvVariables } from "cyberstorm/security/publicEnvVariables"; + +interface LoginProps { type: "discord" | "github" | "overwolf"; authBaseDomain: string; authReturnDomain: string; nextUrl?: string; } -export function buildAuthLoginUrl(props: Props) { +export function buildAuthLoginUrl(props: LoginProps) { return `${props.authBaseDomain}/auth/login/${props.type}/${ props.nextUrl ? `?next=${encodeURIComponent(props.nextUrl)}` : `?next=${encodeURIComponent(`${props.authReturnDomain}/communities/`)}` }`; } + +export function buildLogoutUrl(domain?: string) { + const publicEnvVariables = getPublicEnvVariables(["VITE_AUTH_RETURN_URL"]); + const returnURL = publicEnvVariables.VITE_AUTH_RETURN_URL || ""; + const logoutURL = domain ? `${domain}/logout/` : "/logout"; + return `${logoutURL}?next=${encodeURIComponent(returnURL)}`; +}