set password WIP

This commit is contained in:
zadam
2021-12-29 23:19:05 +01:00
parent 7e48d214ca
commit 4e31af8c84
8 changed files with 101 additions and 17 deletions

View File

@@ -15,7 +15,11 @@ function checkAuth(req, res, next) {
res.redirect("setup");
}
else if (!req.session.loggedIn && !utils.isElectron() && !noAuthentication) {
res.redirect("login");
if (sqlInit.isPasswordSet()) {
res.redirect("login");
} else {
res.redirect("set_password");
}
}
else {
next();
@@ -51,6 +55,14 @@ function checkAppInitialized(req, res, next) {
}
}
function checkPasswordSet(req, res, next) {
if (!utils.isElectron() && !sqlInit.isPasswordSet()) {
res.redirect("set_password");
} else {
next();
}
}
function checkAppNotInitialized(req, res, next) {
if (sqlInit.isDbInitialized()) {
reject(req, res, "App already initialized.");
@@ -101,6 +113,7 @@ module.exports = {
checkAuth,
checkApiAuth,
checkAppInitialized,
checkPasswordSet,
checkAppNotInitialized,
checkApiAuthOrElectron,
checkToken,