Browse Source

user session should be initialized by apps

master
Ruben Meyer 1 year ago
parent
commit
e1299d3857
Signed by: rxbn_ GPG Key ID: BE3BF898BE352FE2
  1. 14
      bin/web/app/routes/main.js

14
bin/web/app/routes/main.js

@ -1,19 +1,27 @@
var express = require('express');
var route = express.Router();
const cfg = require(global['__dirname']+'/bin/config');
route.use((req, res, next) => {
if(!req.session || !req.session.user) {
if(!req.path.startsWith('/api')) {
let path = (global['gds'].cfg.web.rootUrl+'/auth');
let path = (cfg.web.rootUrl+'/auth');
if(global['gds'].cfg.web.doubleSlashCheck) path = path.replace(/\/+/g, "/");
if(cfg.web.doubleSlashCheck) path = path.replace(/\/+/g, "/");
res.redirect(path);
} else {
res.redirect('/auth'+req.path);
}
} else next();
} else {
// initialize User
if(req.session.user.initializeUser) {
// do it
req.session.user.initializeUser = false;
}
next();
}
});
route.get('/', (req, res) => {

Loading…
Cancel
Save