|
@ -2,26 +2,26 @@ const { User } = require("../db/db"); |
|
|
const { addContact } = require("../db/utils"); |
|
|
const { addContact } = require("../db/utils"); |
|
|
|
|
|
|
|
|
function VerifyRoute(req, res) { |
|
|
function VerifyRoute(req, res) { |
|
|
checkVerification(req.body.id, (success, msg, withUserID) => { |
|
|
|
|
|
req.session.verified = success; |
|
|
|
|
|
req.session.verifiedBy = withUserID; |
|
|
|
|
|
|
|
|
checkVerification(req.body.id, (success, msg, withUserID) => { |
|
|
|
|
|
req.session.verified = success; |
|
|
|
|
|
req.session.verifiedBy = withUserID; |
|
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
if (req.session.user) { |
|
|
|
|
|
// If Logged In
|
|
|
|
|
|
addContact(req.session.user, withUserID, (success, msg) => { |
|
|
|
|
|
res |
|
|
|
|
|
.status(success ? 200 : 400) |
|
|
|
|
|
.send({ success: success, message: msg, loggedIn: true }); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// If Not Logged In
|
|
|
|
|
|
res.send({ success: success, message: msg, loggedIn: false }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
if (req.session.user) { |
|
|
|
|
|
// If Logged In
|
|
|
|
|
|
addContact(req.session.user, withUserID, (success, msg) => { |
|
|
|
|
|
res |
|
|
|
|
|
.status(success ? 200 : 400) |
|
|
|
|
|
.send({ success: success, message: msg, loggedIn: true }); |
|
|
|
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
res.status(400).send({ success: success, message: msg }); |
|
|
|
|
|
|
|
|
// If Not Logged In
|
|
|
|
|
|
res.send({ success: success, message: msg, loggedIn: false }); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
res.status(400).send({ success: success, message: msg }); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function checkVerification(id, done) { |
|
|
function checkVerification(id, done) { |
|
|