This commit is contained in:
azivner
2017-10-25 22:39:21 -04:00
parent 5253f680f6
commit 1c733fbfab
10 changed files with 198 additions and 64 deletions

View File

@@ -1,19 +1,31 @@
"use strict";
function checkAuth(req, res, next) {
const migration = require('./migration');
async function checkAuth(req, res, next) {
if (!req.session.loggedIn) {
res.redirect("login");
} else {
}
if (await migration.isDbUpToDate()) {
next();
}
else {
res.redirect("migration");
}
}
function checkApiAuth(req, res, next) {
if (!req.session.loggedIn) {
async function checkApiAuth(req, res, next) {
if (!req.session.loggedIn && req.header("auth") !== "sync") {
res.sendStatus(401);
} else {
}
if (await migration.isDbUpToDate()) {
next();
}
else {
res.sendStatus(409); // need better response than that
}
}
module.exports = {