Fixed verify mail

This commit is contained in:
Moe Poi ~ 2021-11-21 11:37:38 +07:00
parent a9d1f8e9ee
commit 2309e319f5
2 changed files with 4 additions and 3 deletions

View file

@ -241,7 +241,7 @@ router.post("/login", async (req, res) => {
} }
}); });
router.get("/verify-mail", async (req, res) => { router.post("/verify-mail", async (req, res) => {
if (!req.body.token) { if (!req.body.token) {
res.status(400); res.status(400);
res.json({ res.json({
@ -262,6 +262,7 @@ router.get("/verify-mail", async (req, res) => {
if (result[0].verify == 0) { if (result[0].verify == 0) {
var data = { var data = {
verify: 1, verify: 1,
token: randtoken.generate(64),
}; };
conn.query( conn.query(
'UPDATE users SET ? WHERE email ="' + result[0].email + '"', 'UPDATE users SET ? WHERE email ="' + result[0].email + '"',

View file

@ -96,8 +96,8 @@ router.route("/logout")
router.get("/verify-mail", (req, res) => { router.get("/verify-mail", (req, res) => {
controller.verify_mail(req.query.token).then((data) => { controller.verify_mail(req.query.token).then((data) => {
if (data == 200) { if (data[0] == 200) {
res.render("pages/register-verification-success"); res.render("pages/register-verification-completed");
} else { } else {
res.redirect("/"); res.redirect("/");
} }