From 17f3cdf85d36db164a53a5209279471df6fb2032 Mon Sep 17 00:00:00 2001 From: vitshev Date: Fri, 9 Feb 2024 11:07:23 +0100 Subject: [PATCH] fix: oauth should be independent from allowPasswordAuth [#349] --- packages/ui/src/server/index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/server/index.ts b/packages/ui/src/server/index.ts index ea6d122ffa..64ad1cd7e6 100644 --- a/packages/ui/src/server/index.ts +++ b/packages/ui/src/server/index.ts @@ -21,14 +21,24 @@ nodekit.ctx.log('AppConfig details', { appDevMode, }); -const {allowPasswordAuth} = nodekit.config; +const {allowPasswordAuth, ytOAuthSettings} = nodekit.config; + +const authMiddlewares = []; + +if (ytOAuthSettings) { + authMiddlewares.push(authorizationResolver(createOAuthAuthorizationResolver())); +} if (allowPasswordAuth) { + authMiddlewares.push(authorizationResolver(createYTAuthorizationResolver())); +} + +if (authMiddlewares.length) { nodekit.config.appBeforeAuthMiddleware = [ ...(nodekit.config.appBeforeAuthMiddleware || []), - authorizationResolver(createOAuthAuthorizationResolver()), - authorizationResolver(createYTAuthorizationResolver()), + ...authMiddlewares, ]; + nodekit.config.appAuthHandler = createAuthMiddleware(); }