mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-02 01:54:58 +05:00
9 lines
368 B
JavaScript
9 lines
368 B
JavaScript
|
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}`);
|
||
|
};
|
||
|
};
|