mirror of
https://github.com/lowdefy/lowdefy.git
synced 2024-12-09 05:41:08 +08:00
fix: Auth bug fixes.
This commit is contained in:
parent
557669e798
commit
3fe249c36e
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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(
|
||||
|
@ -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'),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user