espid2sensor: Admin-Bootstrap via ADMIN_EMAIL/ADMIN_PASSWORD

Für extern verwaltete Deployments (Portainer, kein direkter Mongo-Zugriff)
wird beim Start automatisch ein Admin-User angelegt, falls die
user-Collection leer ist und ADMIN_EMAIL/ADMIN_PASSWORD gesetzt sind.
Login-Seite zeigt einen Hinweis, solange noch kein User existiert.

Version auf 1.5.0 angehoben.
This commit is contained in:
2026-08-07 06:46:28 +00:00
parent 6ff2ceb76d
commit 7b3403d943
5 changed files with 37 additions and 6 deletions
+5 -3
View File
@@ -7,13 +7,15 @@ export function registerAuthRoutes(app) {
const errText = 'Falsche Email oder falsches Passwort.'
app.get('/login', (req, res) => {
app.get('/login', async (req, res) => {
const version = pkg.version
const vdate = pkg.date
res.render('login', {
const noUsers = (await usersCollection.countDocuments()) === 0;
res.render('login', {
error: null,
version: version,
vdate: vdate
vdate: vdate,
noUsers: noUsers
})
});