some tweaks mainly for electron support

This commit is contained in:
azivner
2017-11-05 17:58:55 -05:00
parent 0481b1b79c
commit b890c9982b
7 changed files with 101 additions and 13 deletions

View File

@@ -1,9 +1,10 @@
"use strict";
const migration = require('./migration');
const utils = require('./utils');
async function checkAuth(req, res, next) {
if (!req.session.loggedIn) {
if (!req.session.loggedIn && !utils.isElectron()) {
res.redirect("login");
}
else if (await migration.isDbUpToDate()) {
@@ -15,7 +16,7 @@ async function checkAuth(req, res, next) {
}
async function checkAuthWithoutMigration(req, res, next) {
if (!req.session.loggedIn) {
if (!req.session.loggedIn && !utils.isElectron()) {
res.redirect("login");
}
else {
@@ -24,7 +25,7 @@ async function checkAuthWithoutMigration(req, res, next) {
}
async function checkApiAuth(req, res, next) {
if (!req.session.loggedIn) {
if (!req.session.loggedIn && !utils.isElectron()) {
res.status(401).send("Not authorized");
}
else if (await migration.isDbUpToDate()) {
@@ -36,7 +37,7 @@ async function checkApiAuth(req, res, next) {
}
async function checkApiAuthWithoutMigration(req, res, next) {
if (!req.session.loggedIn) {
if (!req.session.loggedIn && !utils.isElectron()) {
res.status(401).send("Not authorized");
}
else {