Skip to content

Commit

Permalink
fix: make sure the required env is checked (#306)
Browse files Browse the repository at this point in the history
resolves #301
  • Loading branch information
atinux authored Dec 13, 2024
1 parent 1a79baf commit f030600
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/dropbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/instagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/paypal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/seznam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/oauth/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f030600

Please sign in to comment.