Fix crashing when determining roles when no apps exist
This commit is contained in:
parent
1bcb7a05b5
commit
7c4bf7aedd
|
@ -203,15 +203,24 @@ exports.getAllRoles = async appId => {
|
||||||
if (appId) {
|
if (appId) {
|
||||||
return doWithDB(appId, internal)
|
return doWithDB(appId, internal)
|
||||||
} else {
|
} else {
|
||||||
return internal(getAppDB())
|
let appDB
|
||||||
|
try {
|
||||||
|
appDB = getAppDB()
|
||||||
|
} catch (error) {
|
||||||
|
// We don't have any apps, so we'll just use the built-in roles
|
||||||
|
}
|
||||||
|
return internal(appDB)
|
||||||
}
|
}
|
||||||
async function internal(db) {
|
async function internal(db) {
|
||||||
const body = await db.allDocs(
|
let roles = []
|
||||||
getRoleParams(null, {
|
if (db) {
|
||||||
include_docs: true,
|
const body = await db.allDocs(
|
||||||
})
|
getRoleParams(null, {
|
||||||
)
|
include_docs: true,
|
||||||
let roles = body.rows.map(row => row.doc)
|
})
|
||||||
|
)
|
||||||
|
roles = body.rows.map(row => row.doc)
|
||||||
|
}
|
||||||
const builtinRoles = exports.getBuiltinRoles()
|
const builtinRoles = exports.getBuiltinRoles()
|
||||||
|
|
||||||
// need to combine builtin with any DB record of them (for sake of permissions)
|
// need to combine builtin with any DB record of them (for sake of permissions)
|
||||||
|
|
Loading…
Reference in New Issue