etapi improvements and more tests

This commit is contained in:
zadam
2022-01-12 19:32:23 +01:00
parent 42e85aefdc
commit 28df5d4aa2
36 changed files with 449 additions and 335 deletions

View File

@@ -15,11 +15,7 @@ function checkAuth(req, res, next) {
res.redirect("setup");
}
else if (!req.session.loggedIn && !utils.isElectron() && !noAuthentication) {
if (passwordService.isPasswordSet()) {
res.redirect("login");
} else {
res.redirect("set-password");
}
res.redirect("login");
}
else {
next();
@@ -63,6 +59,14 @@ function checkPasswordSet(req, res, next) {
}
}
function checkPasswordNotSet(req, res, next) {
if (!utils.isElectron() && passwordService.isPasswordSet()) {
res.redirect("login");
} else {
next();
}
}
function checkAppNotInitialized(req, res, next) {
if (sqlInit.isDbInitialized()) {
reject(req, res, "App already initialized.");
@@ -111,6 +115,7 @@ module.exports = {
checkApiAuth,
checkAppInitialized,
checkPasswordSet,
checkPasswordNotSet,
checkAppNotInitialized,
checkApiAuthOrElectron,
checkEtapiToken,