diff --git a/src/routes/LoginRoute.js b/src/routes/LoginRoute.js index 7163367..b1b7a9d 100644 --- a/src/routes/LoginRoute.js +++ b/src/routes/LoginRoute.js @@ -4,8 +4,16 @@ const { addContact, createUser } = require("../db/utils"); function LoginRoute(req, res) { const telegramResponse = req.body.telegramResponse; + authUser(telegramResponse, (success, msg) => { if (success) { + + // User is already logged in + if(req.session.user == telegramResponse.id){ + res.send({authorized: success}); + return; + } + const verified = req.session.verified; const verifiedBy = req.session.verifiedBy; req.session.regenerate(() => { @@ -26,6 +34,7 @@ function LoginRoute(req, res) { res.status(401).send({ authorized: success, message: msg }); } }); + } function authUser(telegramResponse, done) {