Fixing some issues with auth module.
This commit is contained in:
parent
2edb559fcf
commit
ee1a7a69ac
|
@ -1,9 +1,5 @@
|
||||||
let Pouch
|
|
||||||
|
|
||||||
module.exports.getDB = () => {
|
|
||||||
return Pouch
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.setDB = pouch => {
|
module.exports.setDB = pouch => {
|
||||||
Pouch = pouch
|
module.exports.CouchDB = pouch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.CouchDB = null
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
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
|
||||||
// const GoogleStrategy = require("passport-google-oauth").Strategy
|
// const GoogleStrategy = require("passport-google-oauth").Strategy
|
||||||
const CouchDB = require("./db")
|
const database = require("./db")
|
||||||
const { StaticDatabases } = require("./db/utils")
|
const { StaticDatabases } = require("./db/utils")
|
||||||
const { jwt, local, authenticated } = require("./middleware")
|
const { jwt, local, authenticated } = require("./middleware")
|
||||||
const { Cookies, UserStatus } = require("./constants")
|
const { Cookies, UserStatus } = require("./constants")
|
||||||
|
@ -29,7 +28,7 @@ passport.use(new JwtStrategy(jwt.options, jwt.authenticate))
|
||||||
passport.serializeUser((user, done) => done(null, user))
|
passport.serializeUser((user, done) => done(null, user))
|
||||||
|
|
||||||
passport.deserializeUser(async (user, done) => {
|
passport.deserializeUser(async (user, done) => {
|
||||||
const db = new CouchDB(StaticDatabases.USER.name)
|
const db = new database.CouchDB(StaticDatabases.USER.name)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await db.get(user._id)
|
const user = await db.get(user._id)
|
||||||
|
@ -42,7 +41,7 @@ passport.deserializeUser(async (user, done) => {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init(pouch) {
|
init(pouch) {
|
||||||
db.setDB(pouch)
|
database.setDB(pouch)
|
||||||
},
|
},
|
||||||
passport,
|
passport,
|
||||||
Cookies,
|
Cookies,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const jwt = require("jsonwebtoken")
|
const jwt = require("jsonwebtoken")
|
||||||
const { UserStatus } = require("../../constants")
|
const { UserStatus } = require("../../constants")
|
||||||
const CouchDB = require("../../db")
|
const database = require("../../db")
|
||||||
const { StaticDatabases, generateUserID } = require("../../db/utils")
|
const { StaticDatabases, generateUserID } = require("../../db/utils")
|
||||||
const { compare } = require("../../hashing")
|
const { compare } = require("../../hashing")
|
||||||
const env = require("../../environment")
|
const env = require("../../environment")
|
||||||
|
@ -21,7 +21,7 @@ exports.authenticate = async function(username, password, done) {
|
||||||
if (!password) return done(null, false, "Password Required.")
|
if (!password) return done(null, false, "Password Required.")
|
||||||
|
|
||||||
// Check the user exists in the instance DB by email
|
// Check the user exists in the instance DB by email
|
||||||
const db = new CouchDB(StaticDatabases.USER.name)
|
const db = new database.CouchDB(StaticDatabases.USER.name)
|
||||||
|
|
||||||
let dbUser
|
let dbUser
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// need to load environment first
|
// need to load environment first
|
||||||
const env = require("./environment")
|
const env = require("./environment")
|
||||||
|
const CouchDB = require("./db")
|
||||||
|
require("@budibase/auth").init(CouchDB)
|
||||||
const Koa = require("koa")
|
const Koa = require("koa")
|
||||||
const destroyable = require("server-destroy")
|
const destroyable = require("server-destroy")
|
||||||
const electron = require("electron")
|
const electron = require("electron")
|
||||||
|
@ -11,10 +13,6 @@ 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()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// need to load environment first
|
// need to load environment first
|
||||||
const env = require("./environment")
|
const env = require("./environment")
|
||||||
|
const CouchDB = require("./db")
|
||||||
|
require("@budibase/auth").init(CouchDB)
|
||||||
const Koa = require("koa")
|
const Koa = require("koa")
|
||||||
const destroyable = require("server-destroy")
|
const destroyable = require("server-destroy")
|
||||||
const koaBody = require("koa-body")
|
const koaBody = require("koa-body")
|
||||||
|
@ -7,10 +9,6 @@ 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