do not allow users to initialise again once an admin has been created

This commit is contained in:
Martin McKeaveney 2021-05-05 22:06:31 +01:00
parent 1aedba80bd
commit 399c463f52
1 changed files with 11 additions and 0 deletions

View File

@ -61,6 +61,17 @@ exports.save = async ctx => {
}
exports.adminUser = async ctx => {
const db = new CouchDB(GLOBAL_DB)
const response = await db.allDocs(
getGlobalUserParams(null, {
include_docs: true,
})
)
if (response.rows.some(row => row.doc.admin)) {
ctx.throw(403, "You cannot initialise once an admin user has been created.")
}
const { email, password } = ctx.request.body
ctx.request.body = {
email: email,