From f030600d95df66c064cb828671288d3a159dc790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 13 Dec 2024 14:00:01 +0100 Subject: [PATCH] fix: make sure the required env is checked (#306) resolves #301 --- src/runtime/server/lib/oauth/dropbox.ts | 4 ++-- src/runtime/server/lib/oauth/facebook.ts | 4 ++-- src/runtime/server/lib/oauth/google.ts | 4 ++-- src/runtime/server/lib/oauth/instagram.ts | 4 ++-- src/runtime/server/lib/oauth/paypal.ts | 4 ++-- src/runtime/server/lib/oauth/seznam.ts | 4 ++-- src/runtime/server/lib/oauth/twitch.ts | 4 ++-- src/runtime/server/lib/oauth/x.ts | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/runtime/server/lib/oauth/dropbox.ts b/src/runtime/server/lib/oauth/dropbox.ts index f73a206..627f96a 100644 --- a/src/runtime/server/lib/oauth/dropbox.ts +++ b/src/runtime/server/lib/oauth/dropbox.ts @@ -68,8 +68,8 @@ export function defineOAuthDropboxEventHandler({ config, onSuccess, onError }: O const query = getQuery<{ code?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'dropbox', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'dropbox', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/facebook.ts b/src/runtime/server/lib/oauth/facebook.ts index 4411379..7433e3a 100644 --- a/src/runtime/server/lib/oauth/facebook.ts +++ b/src/runtime/server/lib/oauth/facebook.ts @@ -81,8 +81,8 @@ export function defineOAuthFacebookEventHandler({ return onError(event, error) } - if (!config.clientId) { - return handleMissingConfiguration(event, 'facebook', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'facebook', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/google.ts b/src/runtime/server/lib/oauth/google.ts index 6c943d3..581c173 100644 --- a/src/runtime/server/lib/oauth/google.ts +++ b/src/runtime/server/lib/oauth/google.ts @@ -74,8 +74,8 @@ export function defineOAuthGoogleEventHandler({ const query = getQuery<{ code?: string, state?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'google', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'google', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/instagram.ts b/src/runtime/server/lib/oauth/instagram.ts index 51ff94e..21b3cff 100644 --- a/src/runtime/server/lib/oauth/instagram.ts +++ b/src/runtime/server/lib/oauth/instagram.ts @@ -91,8 +91,8 @@ export function defineOAuthInstagramEventHandler({ return onError(event, error) } - if (!config.clientId) { - return handleMissingConfiguration(event, 'instagram', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'instagram', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/paypal.ts b/src/runtime/server/lib/oauth/paypal.ts index 5bf2d70..9f58fff 100644 --- a/src/runtime/server/lib/oauth/paypal.ts +++ b/src/runtime/server/lib/oauth/paypal.ts @@ -75,8 +75,8 @@ export function defineOAuthPaypalEventHandler({ config, onSuccess, onError }: OA const query = getQuery<{ code?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'paypal', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'paypal', ['clientId', 'clientSecret'], onError) } let paypalAPI = 'api-m.paypal.com' diff --git a/src/runtime/server/lib/oauth/seznam.ts b/src/runtime/server/lib/oauth/seznam.ts index 5f3fbfb..c0becd2 100644 --- a/src/runtime/server/lib/oauth/seznam.ts +++ b/src/runtime/server/lib/oauth/seznam.ts @@ -126,8 +126,8 @@ export function defineOAuthSeznamEventHandler({ config, onSuccess, onError }: OA const query = getQuery<{ code?: string, state?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'seznam', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'seznam', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/twitch.ts b/src/runtime/server/lib/oauth/twitch.ts index 4cbcf1f..251df83 100644 --- a/src/runtime/server/lib/oauth/twitch.ts +++ b/src/runtime/server/lib/oauth/twitch.ts @@ -68,8 +68,8 @@ export function defineOAuthTwitchEventHandler({ config, onSuccess, onError }: OA const query = getQuery<{ code?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'twitch', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'twitch', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event) diff --git a/src/runtime/server/lib/oauth/x.ts b/src/runtime/server/lib/oauth/x.ts index 489bfac..f94a41e 100644 --- a/src/runtime/server/lib/oauth/x.ts +++ b/src/runtime/server/lib/oauth/x.ts @@ -80,8 +80,8 @@ export function defineOAuthXEventHandler({ const query = getQuery<{ code?: string }>(event) - if (!config.clientId) { - return handleMissingConfiguration(event, 'x', ['clientId'], onError) + if (!config.clientId || !config.clientSecret) { + return handleMissingConfiguration(event, 'x', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getOAuthRedirectURL(event)