Browse Source

put verification page on webapp

feature/telegramLogin
Nareshkumar Rao 3 years ago
parent
commit
90da863e7b
  1. 23
      app.js

23
app.js

@ -123,7 +123,7 @@ function createQRCode(email, done) {
} }
}).then(user => { }).then(user => {
refreshVerification(user, result => { refreshVerification(user, result => {
const verifyURL = `${process.env.SERVER_API_URL}/verify/${encodeURIComponent(result.verification)}`;
const verifyURL = `${process.env.WEBSITE_URL}/#/verify/${encodeURIComponent(result.verification)}`;
QRCode.toDataURL(verifyURL, { width: 300, height: 300 }, (err, url) => { QRCode.toDataURL(verifyURL, { width: 300, height: 300 }, (err, url) => {
done(err, url); done(err, url);
}) })
@ -192,7 +192,8 @@ app.use(session({
cookie: { cookie: {
secure: true, secure: true,
sameSite: "none", sameSite: "none",
}
},
store: store,
})) }))
app.use(cors({ credentials: true, origin: true, secure: true })); app.use(cors({ credentials: true, origin: true, secure: true }));
app.use(express.json()) app.use(express.json())
@ -241,8 +242,8 @@ app.get('/code', (req, res) => {
}); });
}) })
app.get("/verify/:id", (req, res) => {
checkVerification(req.params.id, (success, msg, withUserID) => {
app.post("/verify", (req, res) => {
checkVerification(req.body.id, (success, msg, withUserID) => {
cookieExpiry = getCookieExpiry(); cookieExpiry = getCookieExpiry();
req.session.verified = success; req.session.verified = success;
req.session.verifiedBy = withUserID; req.session.verifiedBy = withUserID;
@ -250,21 +251,13 @@ app.get("/verify/:id", (req, res) => {
if (success) { if (success) {
if (req.session.user) { // If Logged In if (req.session.user) { // If Logged In
addContact(req.session.user, withUserID, (success, msg) => { addContact(req.session.user, withUserID, (success, msg) => {
if (success) {
res.redirect(`${process.env.WEBSITE_URL}/#/success`)
} else {
res.status(400).send(msg);
}
res.status(success ? 200 : 400).send({ success: success, message: msg, loggedIn: true });
}); });
} else { // If Not Logged In } else { // If Not Logged In
if (success) {
res.redirect(`${process.env.WEBSITE_URL}/#/create`)
} else {
res.status(400).send(msg);
}
res.send({ success: success, message: msg, loggedIn: false })
} }
} else { } else {
res.status(400).send(msg);
res.status(400).send({ success: success, message: msg });
} }
}); });
}); });

Loading…
Cancel
Save