mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
etapi improvements and more tests
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user