Updating auth lib so that it takes in a pouch instance rather than creating its own.
This commit is contained in:
parent
aacfb6adba
commit
9e1315c535
|
@ -12,7 +12,6 @@
|
||||||
"passport-google-auth": "^1.0.2",
|
"passport-google-auth": "^1.0.2",
|
||||||
"passport-google-oauth": "^2.0.0",
|
"passport-google-oauth": "^2.0.0",
|
||||||
"passport-jwt": "^4.0.0",
|
"passport-jwt": "^4.0.0",
|
||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0"
|
||||||
"pouchdb": "^7.2.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
const PouchDB = require("pouchdb")
|
let Pouch
|
||||||
const env = require("../environment")
|
|
||||||
|
|
||||||
// level option is purely for testing (development)
|
module.exports.getDB = () => {
|
||||||
const COUCH_DB_URL =
|
return Pouch
|
||||||
env.COUCH_DB_URL || "http://budibase:budibase@localhost:10000/db/"
|
}
|
||||||
|
|
||||||
const Pouch = PouchDB.defaults({
|
module.exports.setDB = pouch => {
|
||||||
prefix: COUCH_DB_URL,
|
Pouch = pouch
|
||||||
})
|
}
|
||||||
|
|
||||||
module.exports = Pouch
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const db = require("./db")
|
||||||
const passport = require("koa-passport")
|
const passport = require("koa-passport")
|
||||||
const LocalStrategy = require("passport-local").Strategy
|
const LocalStrategy = require("passport-local").Strategy
|
||||||
const JwtStrategy = require("passport-jwt").Strategy
|
const JwtStrategy = require("passport-jwt").Strategy
|
||||||
|
@ -40,6 +41,9 @@ passport.deserializeUser(async (user, done) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
init(pouch) {
|
||||||
|
db.setDB(pouch)
|
||||||
|
},
|
||||||
passport,
|
passport,
|
||||||
Cookies,
|
Cookies,
|
||||||
UserStatus,
|
UserStatus,
|
||||||
|
|
|
@ -11,6 +11,10 @@ const eventEmitter = require("./events")
|
||||||
const automations = require("./automations/index")
|
const automations = require("./automations/index")
|
||||||
const Sentry = require("@sentry/node")
|
const Sentry = require("@sentry/node")
|
||||||
const fileSystem = require("./utilities/fileSystem")
|
const fileSystem = require("./utilities/fileSystem")
|
||||||
|
const auth = require("@budibase/auth")
|
||||||
|
const CouchDB = require("./db")
|
||||||
|
|
||||||
|
auth.init(CouchDB)
|
||||||
|
|
||||||
const app = new Koa()
|
const app = new Koa()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ const { passport } = require("@budibase/auth")
|
||||||
const logger = require("koa-pino-logger")
|
const logger = require("koa-pino-logger")
|
||||||
const http = require("http")
|
const http = require("http")
|
||||||
const api = require("./api")
|
const api = require("./api")
|
||||||
|
const auth = require("@budibase/auth")
|
||||||
|
const CouchDB = require("./db")
|
||||||
|
|
||||||
|
auth.init(CouchDB)
|
||||||
|
|
||||||
const app = new Koa()
|
const app = new Koa()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue