From 31ee1c2d3cc13e560d94df52b73d43f19310ab0f Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao <_accounts@nareshkumarrao.com> Date: Thu, 29 Jul 2021 21:52:18 +0200 Subject: [PATCH] fixed bug re-sending contact verification upon login --- src/routes/LoginRoute.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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) {