trilium/services/auth.js
2017-10-21 21:10:33 -04:00

22 lines
No EOL
347 B
JavaScript

"use strict";
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
};