From b887fd6b9922b6141eab466e0d1c386b9c88b752 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 16 Apr 2021 18:09:34 +0100 Subject: [PATCH] Changing user db to be called global db. --- packages/auth/src/db/utils.js | 4 ++-- packages/auth/src/index.js | 2 +- packages/auth/src/middleware/passport/local.js | 2 +- packages/worker/src/api/controllers/admin/index.js | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 043987fcc4..dc1512c995 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -1,6 +1,6 @@ exports.StaticDatabases = { - USER: { - name: "user-db", + GLOBAL: { + name: "global-db", }, } diff --git a/packages/auth/src/index.js b/packages/auth/src/index.js index 705e07f813..6ac56f8f36 100644 --- a/packages/auth/src/index.js +++ b/packages/auth/src/index.js @@ -28,7 +28,7 @@ passport.use(new JwtStrategy(jwt.options, jwt.authenticate)) passport.serializeUser((user, done) => done(null, user)) passport.deserializeUser(async (user, done) => { - const db = new database.CouchDB(StaticDatabases.USER.name) + const db = new database.CouchDB(StaticDatabases.GLOBAL.name) try { const user = await db.get(user._id) diff --git a/packages/auth/src/middleware/passport/local.js b/packages/auth/src/middleware/passport/local.js index 78ee2eafff..6249050d05 100644 --- a/packages/auth/src/middleware/passport/local.js +++ b/packages/auth/src/middleware/passport/local.js @@ -21,7 +21,7 @@ exports.authenticate = async function(username, password, done) { if (!password) return done(null, false, "Password Required.") // Check the user exists in the instance DB by email - const db = new database.CouchDB(StaticDatabases.USER.name) + const db = new database.CouchDB(StaticDatabases.GLOBAL.name) let dbUser try { diff --git a/packages/worker/src/api/controllers/admin/index.js b/packages/worker/src/api/controllers/admin/index.js index ff0d2997e7..600a8e75f6 100644 --- a/packages/worker/src/api/controllers/admin/index.js +++ b/packages/worker/src/api/controllers/admin/index.js @@ -7,10 +7,10 @@ const { } = require("@budibase/auth") const { UserStatus } = require("../../../constants") -const USER_DB = StaticDatabases.USER.name +const GLOBAL_DB = StaticDatabases.GLOBAL.name exports.userSave = async ctx => { - const db = new CouchDB(USER_DB) + const db = new CouchDB(GLOBAL_DB) const { email, password, _id } = ctx.request.body const hashedPassword = password ? await hash(password) : null let user = { @@ -47,7 +47,7 @@ exports.userSave = async ctx => { } exports.userDelete = async ctx => { - const db = new CouchDB(USER_DB) + const db = new CouchDB(GLOBAL_DB) const dbUser = await db.get(generateUserID(ctx.params.email)) await db.remove(dbUser._id, dbUser._rev) ctx.body = { @@ -57,7 +57,7 @@ exports.userDelete = async ctx => { // called internally by app server user fetch exports.userFetch = async ctx => { - const db = new CouchDB(USER_DB) + const db = new CouchDB(GLOBAL_DB) const response = await db.allDocs( getUserParams(null, { include_docs: true, @@ -75,7 +75,7 @@ exports.userFetch = async ctx => { // called internally by app server user find exports.userFind = async ctx => { - const db = new CouchDB(USER_DB) + const db = new CouchDB(GLOBAL_DB) let user try { user = await db.get(generateUserID(ctx.params.email))