From 9282ecb1a5b8202f25b780cc2f0b63340b188856 Mon Sep 17 00:00:00 2001 From: exit <67079527+exitss@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:52:38 +0000 Subject: [PATCH] fix: add discord oauth error (#316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Chopin --- src/runtime/server/lib/oauth/discord.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/server/lib/oauth/discord.ts b/src/runtime/server/lib/oauth/discord.ts index 1bb27a7a..3df998e4 100644 --- a/src/runtime/server/lib/oauth/discord.ts +++ b/src/runtime/server/lib/oauth/discord.ts @@ -67,12 +67,16 @@ export function defineOAuthDiscordEventHandler({ config, onSuccess, onError }: O profileRequired: true, authorizationParams: {}, }) as OAuthDiscordConfig - const query = getQuery<{ code?: string }>(event) + const query = getQuery<{ code?: string, error?: string }>(event) if (!config.clientId || !config.clientSecret) { return handleMissingConfiguration(event, 'discord', ['clientId', 'clientSecret'], onError) } + if (query.error) { + return handleAccessTokenErrorResponse(event, 'discord', query, onError) + } + const redirectURL = config.redirectURL || getOAuthRedirectURL(event) if (!query.code) {