Skip to content

Commit 55d7eb7

Browse files
authored
Merge pull request #1638 from thunderstore-io/fix--logout-redirect
Update logout redirect
2 parents e8b7731 + 86a84a9 commit 55d7eb7

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

apps/cyberstorm-remix/app/commonComponents/Navigation/Navigation.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ import {
3535
import { faDiscord, faGithub } from "@fortawesome/free-brands-svg-icons";
3636

3737
import { classnames } from "@thunderstore/cyberstorm/src/utils/utils";
38-
import { buildAuthLoginUrl } from "cyberstorm/utils/ThunderstoreAuth";
38+
import {
39+
buildAuthLoginUrl,
40+
buildLogoutUrl,
41+
} from "cyberstorm/utils/ThunderstoreAuth";
3942
import { faArrowUpRight } from "@fortawesome/pro-solid-svg-icons";
4043
import { getPublicEnvVariables } from "cyberstorm/security/publicEnvVariables";
4144

@@ -404,7 +407,7 @@ export function DesktopUserDropdown(props: {
404407
<NewDropDownItem asChild>
405408
<NewLink
406409
primitiveType="link"
407-
href={`${domain}/logout/`}
410+
href={buildLogoutUrl(domain)}
408411
rootClasses="dropdown__item navigation-header__dropdown-item"
409412
>
410413
<NewIcon csMode="inline" noWrapper csVariant="tertiary">
@@ -566,7 +569,7 @@ export function MobileUserPopoverContent(props: {
566569
</NewLink>
567570
<NewLink
568571
primitiveType="link"
569-
href={domain ? `${domain}/logout/` : "/logout"}
572+
href={buildLogoutUrl(domain)}
570573
rootClasses="mobile-navigation__popover-item mobile-navigation__popover--thick"
571574
>
572575
<NewIcon csMode="inline" noWrapper>
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
interface Props {
1+
import { getPublicEnvVariables } from "cyberstorm/security/publicEnvVariables";
2+
3+
interface LoginProps {
24
type: "discord" | "github" | "overwolf";
35
authBaseDomain: string;
46
authReturnDomain: string;
57
nextUrl?: string;
68
}
79

8-
export function buildAuthLoginUrl(props: Props) {
10+
export function buildAuthLoginUrl(props: LoginProps) {
911
return `${props.authBaseDomain}/auth/login/${props.type}/${
1012
props.nextUrl
1113
? `?next=${encodeURIComponent(props.nextUrl)}`
1214
: `?next=${encodeURIComponent(`${props.authReturnDomain}/communities/`)}`
1315
}`;
1416
}
17+
18+
export function buildLogoutUrl(domain?: string) {
19+
const publicEnvVariables = getPublicEnvVariables(["VITE_AUTH_RETURN_URL"]);
20+
const returnURL = publicEnvVariables.VITE_AUTH_RETURN_URL || "";
21+
const logoutURL = domain ? `${domain}/logout/` : "/logout";
22+
return `${logoutURL}?next=${encodeURIComponent(returnURL)}`;
23+
}

0 commit comments

Comments
 (0)