fix that
This commit is contained in:
parent
91607b40ec
commit
8888e7e75e
19
index.js
19
index.js
|
@ -56,20 +56,11 @@ global.checkACL = function(req, perm) {
|
||||||
};
|
};
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
const allowed = ["/", "/login", "/static/*", "/favicon.ico", "/robots.txt"];
|
if (req.session.user) return next();
|
||||||
const isAllowed = allowed.some(pattern => {
|
if (req.path === '/login' || req.path === '/login/') return next();
|
||||||
if (pattern.endsWith('*')) {
|
if (req.path === '/logout' || req.path === '/logout/') return next();
|
||||||
return req.path.startsWith(pattern.slice(0, -1));
|
if (req.path.startsWith('/public/') || req.path === '/favicon.ico' || req.path === '/robots.txt') return next();
|
||||||
}
|
res.redirect('/login?err=4');
|
||||||
return req.path === pattern;
|
|
||||||
});
|
|
||||||
if (isAllowed) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
if (!req.session.user) {
|
|
||||||
return res.redirect('/login?err=4');
|
|
||||||
}
|
|
||||||
res.redirect('/login')
|
|
||||||
});
|
});
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
Loading…
Reference in a new issue