trilium/services/auth.js
2017-10-15 19:47:05 -04:00

20 lines
No EOL
332 B
JavaScript

function checkAuth(req, res, next) {
if (!req.session.loggedIn) {
res.redirect("login");
} else {
next();
}
}
function checkApiAuth(req, res, next) {
if (!req.session.loggedIn) {
res.sendStatus(401);
} else {
next();
}
}
module.exports = {
checkAuth,
checkApiAuth
};