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