From 865569c2f785fd7fc1082673601d85f9ba1e9fa3 Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao <_accounts@nareshkumarrao.com> Date: Sun, 25 Jul 2021 19:54:07 +0200 Subject: [PATCH] register contact on account create --- index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index dd06231..688a7d8 100644 --- a/index.js +++ b/index.js @@ -182,7 +182,13 @@ app.post('/create', (req, res) => { req.session.cookie.expires = cookieExpiry; req.session.user = reqEmail; res.cookie("authorized", success, { domain: process.env.COOKIE_DOMAIN.split(","), sameSite: "none", secure: true, expires: cookieExpiry }); - res.send({ success: success, message: msg }); + if(success){ + addContact(req.session.user, req.session.verifiedBy, (sucesss, msg)=>{ + res.send({ success: success, message: msg }); + }); + }else{ + res.send({ success: success, message: msg }); + } }); } else { res.status(401).send("Not verified"); @@ -190,7 +196,6 @@ app.post('/create', (req, res) => { }) app.get('/code', (req, res) => { - console.log(req.session) if (!req.session.user) { res.status(401).send("Not logged in"); return; @@ -201,14 +206,15 @@ app.get('/code', (req, res) => { }) app.get("/verify/:id", (req, res) => { - checkVerification(req.params.id, (success, msg, withUser) => { + checkVerification(req.params.id, (success, msg, withUserID) => { cookieExpiry = getCookieExpiry(); req.session.cookie.expires = cookieExpiry; req.session.verified = success; + req.session.verifiedBy = withUserID; if (success) { if (req.session.user) { // If Logged In - addContact(req.session.user, withUser, (success, msg) => { + addContact(req.session.user, withUserID, (success, msg) => { if (success) { res.redirect(`${process.env.WEBSITE_URL}/#/success`) } else {