trilium/services/auth.js

22 lines
347 B
JavaScript
Raw Normal View History

2017-10-22 09:10:33 +08:00
"use strict";
2017-10-16 04:32:49 +08:00
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
};