Browse Source

Merge branch 'development' of github.com:naresh97/ssr-tracing-backend into development

pull/5/head
Nareshkumar Rao 3 years ago
parent
commit
a77d456b7a
  1. 2
      src/routes/LoginRoute.js
  2. 16
      src/routes/TelegramWebhookRoute.js

2
src/routes/LoginRoute.js

@ -7,7 +7,6 @@ function LoginRoute(req, res) {
authUser(telegramResponse, (success, msg) => { authUser(telegramResponse, (success, msg) => {
if (success) { if (success) {
// User is already logged in // User is already logged in
if (req.session.user == telegramResponse.id) { if (req.session.user == telegramResponse.id) {
res.send({ authorized: success }); res.send({ authorized: success });
@ -34,7 +33,6 @@ function LoginRoute(req, res) {
res.status(401).send({ authorized: success, message: msg }); res.status(401).send({ authorized: success, message: msg });
} }
}); });
} }
function authUser(telegramResponse, done) { function authUser(telegramResponse, done) {

16
src/routes/TelegramWebhookRoute.js

@ -22,6 +22,7 @@ function TelegramWebhookRoute(req, res) {
}); });
} }
} }
});
} }
catch(e){ catch(e){
console.log("Could not get Telegram Message"); console.log("Could not get Telegram Message");
@ -68,20 +69,25 @@ function userInfected(telegramID, doneCallback) {
where: { where: {
telegram: telegramID, telegram: telegramID,
}, },
}).then((user) => {
})
.then((user) => {
if (!user) { if (!user) {
done({ saved: false }); done({ saved: false });
} else { } else {
user.isInfected = true; user.isInfected = true;
user.save().then(result => {
user
.save()
.then((result) => {
if (result) { if (result) {
doneCallback({ saved: true }); doneCallback({ saved: true });
} }
}).catch(err=>{doneCallback({saved: false})});
})
.catch((err) => {
doneCallback({ saved: false });
});
} }
}) })
.catch(err=>{
.catch((err) => {
doneCallback({ saved: false }); doneCallback({ saved: false });
}); });
} }

Loading…
Cancel
Save