From 0d98f3b44299883ba1593d9c1ab4d8b5c0fc609c Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Thu, 19 Nov 2020 20:42:49 +0000 Subject: [PATCH] Another quick fix for apps to work again. --- packages/server/src/middleware/authenticated.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/server/src/middleware/authenticated.js b/packages/server/src/middleware/authenticated.js index f606ec6239..497c24699d 100644 --- a/packages/server/src/middleware/authenticated.js +++ b/packages/server/src/middleware/authenticated.js @@ -23,12 +23,10 @@ module.exports = async (ctx, next) => { appId = cookieAppId } - let token - if (isClient(ctx)) { - ctx.auth.authenticated = AuthTypes.APP - token = ctx.cookies.get(getCookieName(appId)) - } else { - ctx.auth.authenticated = AuthTypes.BUILDER + let token = ctx.cookies.get(getCookieName(appId)) + let authType = AuthTypes.APP + if (!token && !isClient(ctx)) { + authType = AuthTypes.BUILDER token = ctx.cookies.get(getCookieName()) } @@ -44,6 +42,7 @@ module.exports = async (ctx, next) => { } try { + ctx.auth.authenticated = authType const jwtPayload = jwt.verify(token, ctx.config.jwtSecret) ctx.appId = appId ctx.auth.apiKey = jwtPayload.apiKey