From 249df467708e54b284566e0d2b8dc0a73750e158 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Fri, 23 Jul 2021 11:38:17 +0100 Subject: [PATCH] Mark google activated by default for old configs --- .../server/src/api/routes/tests/misc.spec.js | 8 +++++++- .../src/api/controllers/admin/configs.js | 20 +++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/routes/tests/misc.spec.js b/packages/server/src/api/routes/tests/misc.spec.js index 04a5c62431..b1dd683060 100644 --- a/packages/server/src/api/routes/tests/misc.spec.js +++ b/packages/server/src/api/routes/tests/misc.spec.js @@ -31,7 +31,13 @@ describe("run misc tests", () => { describe("/version", () => { it("should confirm version", async () => { const res = await request.get("/version").expect(200) - expect(res.text.split(".").length).toEqual(3) + const text = res.text + if (text.includes("alpha")) { + expect(text.split(".").length).toEqual(4) + } else { + expect(text.split(".").length).toEqual(3) + } + }) }) diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index 7dfb5b75be..4e907ed356 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -149,16 +149,16 @@ exports.publicSettings = async function (ctx) { config = publicConfig } - config.config.google = !googleConfig - ? !!googleConfig - : !googleConfig.config.activated - ? false - : true - config.config.oidc = !oidcConfig - ? !!oidcConfig - : !oidcConfig.config.configs[0].activated - ? false - : true + // google button flag + const googleActivated = + googleConfig.config.activated == undefined || // activated by default for configs pre-activated flag + googleConfig.config.activated + config.config.google = !googleConfig ? false : googleActivated + + // oidc button flag + const oidcActivated = !oidcConfig.config.configs[0].activated + config.config.oidc = !oidcConfig ? false : oidcActivated + ctx.body = config } catch (err) { ctx.throw(err.status, err)