dynamic oauth link

This commit is contained in:
Joonas 2023-01-21 21:48:33 +02:00
parent d2e07083b3
commit 01ede463c7
1 changed files with 13 additions and 2 deletions

View File

@ -119,7 +119,14 @@ export async function loader({ request }) {
},
});
const session = await getSession(request.headers.get("Cookie"));
if (!session.has("userId")) return json({ countyData });
if (!session.has("userId"))
return json({
countyData,
linkParams: {
id: process.env.OSU_CLIENT_ID,
uri: process.env.OSU_REDIRECT_URI,
},
});
const me = await getMe(session.get("userId"));
@ -182,7 +189,11 @@ export default function Index() {
</div>
) : (
<a
href={`https://osu.ppy.sh/oauth/authorize?client_id=20062&redirect_uri=http://localhost:3000/auth&response_type=code&state=${useAuthenticityToken()}`}
href={`https://osu.ppy.sh/oauth/authorize?client_id=${
data.linkParams.id
}&redirect_uri=${
data.linkParams.uri
}&response_type=code&state=${useAuthenticityToken()}`}
referrerPolicy="no-referrer"
className="rounded-full border border-ctp-surface0 bg-ctp-surface0 px-4 py-2 shadow-md
shadow-ctp-overlay0 hover:bg-ctp-surface1 hover:shadow-ctp-overlay2"