diff --git a/packages/api/src/auth/callbacks/createRedirectCallback.js b/packages/api/src/auth/callbacks/createRedirectCallback.js index 59be3e5fd..3750697ca 100644 --- a/packages/api/src/auth/callbacks/createRedirectCallback.js +++ b/packages/api/src/auth/callbacks/createRedirectCallback.js @@ -25,20 +25,17 @@ function createRedirectCallback({ authConfig, plugins }) { if (redirectCallbackPlugins.length === 0) return undefined; + if (redirectCallbackPlugins.length !== 1) { + throw new Error('More than one auth redirect callbacks are configured. Only one is allowed.'); + } + const [plugin] = redirectCallbackPlugins; + async function redirectCallback({ url, baseUrl }) { - let callbackUrl; - - // TODO: Is there a point in running all the callbacks if only the last one is used? - // Else we can enforce only one. - for (const plugin of redirectCallbackPlugins) { - callbackUrl = await plugin.fn({ - properties: plugin.properties ?? {}, - baseUrl, - url, - }); - } - - return callbackUrl; + return plugin.fn({ + properties: plugin.properties ?? {}, + baseUrl, + url, + }); } return redirectCallback; } diff --git a/packages/build/src/build/buildAuth/validateAuthConfig.js b/packages/build/src/build/buildAuth/validateAuthConfig.js index 5aacf3ee9..2cf5a9101 100644 --- a/packages/build/src/build/buildAuth/validateAuthConfig.js +++ b/packages/build/src/build/buildAuth/validateAuthConfig.js @@ -39,6 +39,9 @@ async function validateAuthConfig({ components }) { if (type.isNone(components.auth.providers)) { components.auth.providers = []; } + if (type.isNone(components.auth.theme)) { + components.auth.theme = {}; + } const { valid } = validate({ schema: lowdefySchema.definitions.authConfig, diff --git a/packages/client/src/auth/createAuthMethods.js b/packages/client/src/auth/createAuthMethods.js index 9f54f3098..143a9016f 100644 --- a/packages/client/src/auth/createAuthMethods.js +++ b/packages/client/src/auth/createAuthMethods.js @@ -37,7 +37,7 @@ function getCallbackUrl({ lowdefy, callbackUrl = {} }) { function createAuthMethods(lowdefy, auth) { // login and logout are Lowdefy function that handle action params // signIn and signOut are the next-auth methods - function login({ providerId, callbackUrl, authUrl = {} }) { + function login({ providerId, callbackUrl, authUrl = {} } = {}) { // TODO: if only one provider exists, pass provider here // to link directly to provider auth.signIn( diff --git a/packages/server-dev/manager/watchers/nextBuildWatcher.mjs b/packages/server-dev/manager/watchers/nextBuildWatcher.mjs index ff5aee299..7b768282b 100644 --- a/packages/server-dev/manager/watchers/nextBuildWatcher.mjs +++ b/packages/server-dev/manager/watchers/nextBuildWatcher.mjs @@ -23,6 +23,7 @@ import setupWatcher from '../utils/setupWatcher.mjs'; const hashes = {}; const watchedFiles = [ + 'build/auth.json', 'build/config.json', 'build/plugins/actions.js', 'build/plugins/blocks.js', @@ -86,6 +87,7 @@ async function nextBuildWatcher(context) { watchDotfiles: true, watchPaths: [ path.join(context.directories.build, 'plugins'), + path.join(context.directories.build, 'auth.json'), path.join(context.directories.build, 'config.json'), path.join(context.directories.server, 'package.json'), ],