Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -404,7 +407,7 @@ export function DesktopUserDropdown(props: {
<NewDropDownItem asChild>
<NewLink
primitiveType="link"
href={`${domain}/logout/`}
href={buildLogoutUrl(domain)}
rootClasses="dropdown__item navigation-header__dropdown-item"
>
<NewIcon csMode="inline" noWrapper csVariant="tertiary">
Expand Down Expand Up @@ -566,7 +569,7 @@ export function MobileUserPopoverContent(props: {
</NewLink>
<NewLink
primitiveType="link"
href={domain ? `${domain}/logout/` : "/logout"}
href={buildLogoutUrl(domain)}
rootClasses="mobile-navigation__popover-item mobile-navigation__popover--thick"
>
<NewIcon csMode="inline" noWrapper>
Expand Down
13 changes: 11 additions & 2 deletions apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx
Original file line number Diff line number Diff line change
@@ -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)}`;
}
Loading