|
@ -4,8 +4,16 @@ const { addContact, createUser } = require("../db/utils"); |
|
|
|
|
|
|
|
|
function LoginRoute(req, res) { |
|
|
function LoginRoute(req, res) { |
|
|
const telegramResponse = req.body.telegramResponse; |
|
|
const telegramResponse = req.body.telegramResponse; |
|
|
|
|
|
|
|
|
authUser(telegramResponse, (success, msg) => { |
|
|
authUser(telegramResponse, (success, msg) => { |
|
|
if (success) { |
|
|
if (success) { |
|
|
|
|
|
|
|
|
|
|
|
// User is already logged in
|
|
|
|
|
|
if(req.session.user == telegramResponse.id){ |
|
|
|
|
|
res.send({authorized: success}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const verified = req.session.verified; |
|
|
const verified = req.session.verified; |
|
|
const verifiedBy = req.session.verifiedBy; |
|
|
const verifiedBy = req.session.verifiedBy; |
|
|
req.session.regenerate(() => { |
|
|
req.session.regenerate(() => { |
|
@ -26,6 +34,7 @@ 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) { |
|
|