fix url encoded params for discord auth
Docker / Build and push Docker image (web) (push) Successful in 15m20s Details
Docker / Build and push Docker image (bot) (push) Successful in 15m35s Details
Docker / Build and push Docker image (database) (push) Successful in 13m44s Details

This commit is contained in:
DataHearth 2023-08-09 14:52:13 +02:00
parent dc84416985
commit 47e7baa4d5
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
1 changed files with 9 additions and 6 deletions

View File

@ -59,12 +59,15 @@ const handleAuth: Handle = async ({ resolve, event }) => {
throw redirect(303, '/login');
}
if (event.url.pathname === '/auth/discord')
throw redirect(
302,
'https://discord.com/api/oauth2/authorize?client_id=1099740412471672913&redirect_uri=http%3A%2F%2Flocalhost%3A5173%2Fauth%2Fcallback%2Fdiscord&response_type=code&scope=identify'
);
else if (event.url.pathname === '/auth/callback/discord') {
if (event.url.pathname === '/auth/discord') {
const params = new URLSearchParams({
client_id: env.CLIENT_ID,
redirect_uri: `${env.ORIGIN}/auth/callback/discord`,
response_type: 'code',
scope: 'identify'
});
throw redirect(302, `https://discord.com/api/oauth2/authorize?${params.toString()}`);
} else if (event.url.pathname === '/auth/callback/discord') {
const code = event.url.searchParams.get('code');
if (!code) {
console.error(`failed to get code in callback url: ${event.url}`);