Skip to content

Commit 7193069

Browse files
authored
Merge pull request #1484 from thunderstore-io/06-23-potentially_fix_logins_on_new_site
Potentially fix logins
2 parents 43ef917 + 343852a commit 7193069

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

apps/cyberstorm-remix/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ PUBLIC_SITE_URL=http://thunderstore.temp
22
PUBLIC_API_URL=http://thunderstore.temp
33
AUTH_ENABLED=
44
AUTH_SECRET=development
5-
PUBLIC_AUTH_BASE_URL=https://auth.thunderstore.io/auth/login
6-
PUBLIC_AUTH_RETURN_URL=?next=https%3A%2F%2Fbeta.thunderstore.io%2F
5+
PUBLIC_AUTH_BASE_URL=https://auth.thunderstore.io
6+
PUBLIC_AUTH_RETURN_URL=https%3A%2F%2Fnew.thunderstore.io
77
PUBLIC_AUTH_DISCORD_URL=$PUBLIC_AUTH_BASE_URL/discord/
88
PUBLIC_AUTH_GITHUB_URL=$PUBLIC_AUTH_BASE_URL/github/
99
PUBLIC_AUTH_OVERWOLF_URL=$PUBLIC_AUTH_BASE_URL/overwolf/

apps/cyberstorm-remix/app/root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export async function loader() {
8686
"PUBLIC_API_URL",
8787
"PUBLIC_CLIENT_SENTRY_DSN",
8888
"PUBLIC_SITE_URL",
89+
"PUBLIC_AUTH_BASE_URL",
90+
"PUBLIC_AUTH_RETURN_URL",
8991
]),
9092
},
9193
};

apps/cyberstorm-remix/cyberstorm/security/publicEnvVariables.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ type rootLoaderType = {
88
PUBLIC_API_URL?: string;
99
PUBLIC_CLIENT_SENTRY_DSN?: string;
1010
PUBLIC_SITE_URL?: string;
11+
PUBLIC_AUTH_BASE_URL?: string;
12+
PUBLIC_AUTH_RETURN_URL?: string;
1113
};
1214
};
1315
};
@@ -23,12 +25,18 @@ export const isRootLoaderData = (obj: unknown): obj is rootLoaderType =>
2325
(typeof obj.root.envStuff.ENV.PUBLIC_CLIENT_SENTRY_DSN === "string" ||
2426
typeof obj.root.envStuff.ENV.PUBLIC_CLIENT_SENTRY_DSN === "undefined") &&
2527
(typeof obj.root.envStuff.ENV.PUBLIC_SITE_URL === "string" ||
26-
typeof obj.root.envStuff.ENV.PUBLIC_SITE_URL === "undefined");
28+
typeof obj.root.envStuff.ENV.PUBLIC_SITE_URL === "undefined") &&
29+
(typeof obj.root.envStuff.ENV.PUBLIC_AUTH_BASE_URL === "string" ||
30+
typeof obj.root.envStuff.ENV.PUBLIC_AUTH_BASE_URL === "undefined") &&
31+
(typeof obj.root.envStuff.ENV.PUBLIC_AUTH_RETURN_URL === "string" ||
32+
typeof obj.root.envStuff.ENV.PUBLIC_AUTH_RETURN_URL === "undefined");
2733

2834
export type publicEnvVariablesKeys =
2935
| "SITE_URL"
3036
| "API_URL"
31-
| "CLIENT_SENTRY_DSN";
37+
| "CLIENT_SENTRY_DSN"
38+
| "AUTH_BASE_URL"
39+
| "AUTH_RETURN_URL";
3240

3341
export type PublicPrefix<envVariable extends string> = `PUBLIC_${envVariable}`;
3442

apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ interface Props {
66
}
77

88
export function buildAuthLoginUrl(props: Props) {
9-
const PUBLIC_API_URL = getPublicEnvVariables([
10-
"PUBLIC_API_URL",
11-
]).PUBLIC_API_URL;
12-
return `${PUBLIC_API_URL}/auth/login/${props.type}/${
9+
const { PUBLIC_AUTH_BASE_URL, PUBLIC_AUTH_RETURN_URL } =
10+
getPublicEnvVariables(["PUBLIC_AUTH_BASE_URL", "PUBLIC_AUTH_RETURN_URL"]);
11+
return `${PUBLIC_AUTH_BASE_URL}/auth/login/${props.type}/${
1312
props.nextUrl
1413
? `?next=${encodeURIComponent(props.nextUrl)}`
15-
: `?next=${encodeURIComponent(`${PUBLIC_API_URL}/communities/`)}`
14+
: `?next=${encodeURIComponent(`${PUBLIC_AUTH_RETURN_URL}/communities/`)}`
1615
}`;
1716
}

0 commit comments

Comments
 (0)