fix imports
This commit is contained in:
parent
9fdff36b54
commit
c273152126
|
@ -1,29 +1,9 @@
|
||||||
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 constants = require("./constants")
|
const { StaticDatabases } = require("./db/utils")
|
||||||
const { StaticDatabases, DocumentTypes } = require("./db/utils")
|
const { jwt, local, authenticated, google } = require("./middleware")
|
||||||
const { jwt, local, google, authenticated } = require("./middleware")
|
|
||||||
const { Cookies, UserStatus } = require("./constants")
|
|
||||||
const { hash, compare } = require("./hashing")
|
|
||||||
const {
|
|
||||||
getAppId,
|
|
||||||
setCookie,
|
|
||||||
getCookie,
|
|
||||||
clearCookie,
|
|
||||||
isClient,
|
|
||||||
} = require("./utils")
|
|
||||||
const { setDB, getDB } = require("./db")
|
const { setDB, getDB } = require("./db")
|
||||||
const {
|
|
||||||
generateUserID,
|
|
||||||
getUserParams,
|
|
||||||
generateGroupID,
|
|
||||||
getGroupParams,
|
|
||||||
getEmailFromUserID,
|
|
||||||
generateConfigID,
|
|
||||||
getConfigParams,
|
|
||||||
determineScopedConfig,
|
|
||||||
} = require("./db/utils")
|
|
||||||
|
|
||||||
// Strategies
|
// Strategies
|
||||||
passport.use(new LocalStrategy(local.options, local.authenticate))
|
passport.use(new LocalStrategy(local.options, local.authenticate))
|
||||||
|
@ -55,30 +35,8 @@ module.exports = {
|
||||||
auth: {
|
auth: {
|
||||||
buildAuthMiddleware: authenticated,
|
buildAuthMiddleware: authenticated,
|
||||||
passport,
|
passport,
|
||||||
middlewares: {
|
google,
|
||||||
google,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
constants,
|
|
||||||
passport,
|
|
||||||
Cookies,
|
|
||||||
UserStatus,
|
|
||||||
DocumentTypes,
|
|
||||||
StaticDatabases,
|
StaticDatabases,
|
||||||
generateUserID,
|
constants: require("./constants"),
|
||||||
getUserParams,
|
|
||||||
generateGroupID,
|
|
||||||
getGroupParams,
|
|
||||||
getEmailFromUserID,
|
|
||||||
generateConfigID,
|
|
||||||
getConfigParams,
|
|
||||||
determineScopedConfig,
|
|
||||||
hash,
|
|
||||||
compare,
|
|
||||||
getAppId,
|
|
||||||
setCookie,
|
|
||||||
getCookie,
|
|
||||||
clearCookie,
|
|
||||||
authenticated,
|
|
||||||
isClient,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const CouchDB = require("../../../db")
|
const CouchDB = require("../../../db")
|
||||||
const { StaticDatabases, determineScopedConfig } = require("@budibase/auth")
|
const authPkg = require("@budibase/auth")
|
||||||
const { generateConfigID, getConfigParams } = require("@budibase/auth")
|
const { utils, StaticDatabases } = authPkg
|
||||||
|
|
||||||
const GLOBAL_DB = StaticDatabases.GLOBAL.name
|
const GLOBAL_DB = StaticDatabases.GLOBAL.name
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ exports.save = async function(ctx) {
|
||||||
|
|
||||||
// Config does not exist yet
|
// Config does not exist yet
|
||||||
if (!configDoc._id) {
|
if (!configDoc._id) {
|
||||||
configDoc._id = generateConfigID({
|
configDoc._id = utils.generateConfigID({
|
||||||
type,
|
type,
|
||||||
group,
|
group,
|
||||||
user,
|
user,
|
||||||
|
@ -33,7 +33,7 @@ exports.save = async function(ctx) {
|
||||||
exports.fetch = async function(ctx) {
|
exports.fetch = async function(ctx) {
|
||||||
const db = new CouchDB(GLOBAL_DB)
|
const db = new CouchDB(GLOBAL_DB)
|
||||||
const response = await db.allDocs(
|
const response = await db.allDocs(
|
||||||
getConfigParams(undefined, {
|
utils.getConfigParams(undefined, {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -60,7 +60,7 @@ exports.find = async function(ctx) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Find the config with the most granular scope based on context
|
// Find the config with the most granular scope based on context
|
||||||
const scopedConfig = await determineScopedConfig(db, {
|
const scopedConfig = await authPkg.db.determineScopedConfig(db, {
|
||||||
type: ctx.params.type,
|
type: ctx.params.type,
|
||||||
user: userId,
|
user: userId,
|
||||||
group,
|
group,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const { determineScopedConfig } = require("@budibase/auth")
|
|
||||||
const authPkg = require("@budibase/auth")
|
const authPkg = require("@budibase/auth")
|
||||||
const { google } = require("@budibase/auth/src/middleware")
|
const { google } = require("@budibase/auth/src/middleware")
|
||||||
const { Configs } = require("../../constants")
|
const { Configs } = require("../../constants")
|
||||||
const CouchDB = require("../../db")
|
const CouchDB = require("../../db")
|
||||||
const { clearCookie } = authPkg.utils
|
const { clearCookie } = authPkg.utils
|
||||||
const { Cookies } = authPkg
|
const { Cookies } = authPkg.constants
|
||||||
const { passport } = authPkg.auth
|
const { passport } = authPkg.auth
|
||||||
|
|
||||||
const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name
|
const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name
|
||||||
|
@ -46,7 +45,7 @@ exports.logout = async ctx => {
|
||||||
*/
|
*/
|
||||||
exports.googlePreAuth = async (ctx, next) => {
|
exports.googlePreAuth = async (ctx, next) => {
|
||||||
const db = new CouchDB(GLOBAL_DB)
|
const db = new CouchDB(GLOBAL_DB)
|
||||||
const config = await determineScopedConfig(db, {
|
const config = await authPkg.db.determineScopedConfig(db, {
|
||||||
type: Configs.GOOGLE,
|
type: Configs.GOOGLE,
|
||||||
group: ctx.query.group,
|
group: ctx.query.group,
|
||||||
})
|
})
|
||||||
|
@ -60,7 +59,7 @@ exports.googlePreAuth = async (ctx, next) => {
|
||||||
exports.googleAuth = async (ctx, next) => {
|
exports.googleAuth = async (ctx, next) => {
|
||||||
const db = new CouchDB(GLOBAL_DB)
|
const db = new CouchDB(GLOBAL_DB)
|
||||||
|
|
||||||
const config = await determineScopedConfig(db, {
|
const config = await authPkg.db.determineScopedConfig(db, {
|
||||||
type: Configs.GOOGLE,
|
type: Configs.GOOGLE,
|
||||||
group: ctx.query.group,
|
group: ctx.query.group,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue