mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
set correct content type for error messages
This commit is contained in:
@@ -88,17 +88,23 @@ function checkEtapiToken(req, res, next) {
|
||||
function reject(req, res, message) {
|
||||
log.info(`${req.method} ${req.path} rejected with 401 ${message}`);
|
||||
|
||||
res.status(401).send(message);
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(401)
|
||||
.send(message);
|
||||
}
|
||||
|
||||
function checkCredentials(req, res, next) {
|
||||
if (!sqlInit.isDbInitialized()) {
|
||||
res.status(400).send('Database is not initialized yet.');
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(400)
|
||||
.send('Database is not initialized yet.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!passwordService.isPasswordSet()) {
|
||||
res.status(400).send('Password has not been set yet. Please set a password and repeat the action');
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(400)
|
||||
.send('Password has not been set yet. Please set a password and repeat the action');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +115,9 @@ function checkCredentials(req, res, next) {
|
||||
// username is ignored
|
||||
|
||||
if (!passwordEncryptionService.verifyPassword(password)) {
|
||||
res.status(401).send('Incorrect password');
|
||||
res.setHeader("Content-Type", "text/plain")
|
||||
.status(401)
|
||||
.send('Incorrect password');
|
||||
}
|
||||
else {
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user