fix url encoded params for discord auth
This commit is contained in:
parent
dc84416985
commit
47e7baa4d5
|
@ -59,12 +59,15 @@ const handleAuth: Handle = async ({ resolve, event }) => {
|
||||||
throw redirect(303, '/login');
|
throw redirect(303, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.url.pathname === '/auth/discord')
|
if (event.url.pathname === '/auth/discord') {
|
||||||
throw redirect(
|
const params = new URLSearchParams({
|
||||||
302,
|
client_id: env.CLIENT_ID,
|
||||||
'https://discord.com/api/oauth2/authorize?client_id=1099740412471672913&redirect_uri=http%3A%2F%2Flocalhost%3A5173%2Fauth%2Fcallback%2Fdiscord&response_type=code&scope=identify'
|
redirect_uri: `${env.ORIGIN}/auth/callback/discord`,
|
||||||
);
|
response_type: 'code',
|
||||||
else if (event.url.pathname === '/auth/callback/discord') {
|
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');
|
const code = event.url.searchParams.get('code');
|
||||||
if (!code) {
|
if (!code) {
|
||||||
console.error(`failed to get code in callback url: ${event.url}`);
|
console.error(`failed to get code in callback url: ${event.url}`);
|
||||||
|
|
Loading…
Reference in New Issue