JaBa/dashboard/auth/CheckAuth.js

9 lines
367 B
JavaScript
Raw Normal View History

2022-01-04 02:18:28 +05:00
module.exports = async (req, res, next) => {
if (req.session.user) return next();
else {
const redirectURL = ((req.originalUrl.includes("login") || req.originalUrl === "/") ? "/selector" : req.originalUrl);
const state = Math.random().toString(36).substring(5);
req.client.states[state] = redirectURL;
return res.redirect(`/api/login?state=${state}`);
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
};