Use transaction and check root on server init

This commit is contained in:
advplyr committed 2026-10-04 20:03:56 -05:00
1 parent 2a0507ffc6
commit 34715558df
3 files changed
+22 -6

No files matched your search

+5 -1
View File
@@ -472,7 +472,11 @@ class Server {
const rootUsername = newRoot.username || 'root'
const rootPash = newRoot.password ? await this.auth.localAuthStrategy.hashPassword(newRoot.password) : ''
if (!rootPash) Logger.warn(`[Server] Creating root user with no password`)
await Database.createRootUser(rootUsername, rootPash, this.auth)
const created = await Database.createRootUser(rootUsername, rootPash, this.auth)
if (!created) {
Logger.error(`[Server] attempt to init server when server already has a root user`)
return res.sendStatus(500)
}
res.sendStatus(200)
}