fix: 🐛 init error with totp

This commit is contained in:
Jin
2025-03-28 02:37:12 +01:00
parent 5742d3068e
commit ea7fbb154f
4 changed files with 8 additions and 10 deletions

View File

@@ -14,13 +14,15 @@ import type { NextFunction, Request, Response } from "express";
const noAuthentication = config.General && config.General.noAuthentication === true;
function checkAuth(req: Request, res: Response, next: NextFunction) {
if (!sqlInit.isDbInitialized()) {
res.redirect('setup');
}
const currentTotpStatus = totp.isTotpEnabled();
const currentSsoStatus = openID.isOpenIDEnabled();
const lastAuthState = req.session.lastAuthState || { totpEnabled: false, ssoEnabled: false };
if (!sqlInit.isDbInitialized()) {
res.redirect('setup');
} else if (isElectron) {
if (isElectron) {
next();
return;
} else if (currentTotpStatus !== lastAuthState.totpEnabled || currentSsoStatus !== lastAuthState.ssoEnabled) {