Update verify mail

This commit is contained in:
Moe Poi ~ 2021-11-17 15:52:36 +07:00
parent e1c0a2dea4
commit 7b808c5ea5
3 changed files with 19 additions and 4 deletions

View file

@ -56,9 +56,16 @@ function login(email, password, ua, ip) {
.catch(error => [error.status, []]) .catch(error => [error.status, []])
} }
function verify_mail(token) {
return axios.get(HOST + '/verify-mail', { params: { token: token } })
.then(response => response.status)
.catch(error => console.log(error))
}
module.exports = { module.exports = {
getProducts, getProducts,
getProduct, getProduct,
register, register,
login login,
verify_mail
} }

View file

@ -76,7 +76,7 @@ router.post('/register', async (req, res) => {
var token = randtoken.generate(20); var token = randtoken.generate(20);
if (result[0].verify == 0) { if (result[0].verify == 0) {
let subject = "Account Verification - Nekoya"; let subject = "Account Verification - Nekoya";
let content = `<p>Hello!!! Please click this link <a href="${config.host}/verify-email?token=${token}">link</a> to verify your account!!! Thanks!!!</p>`; let content = `<p>Hello!!! Please click this link <a href="${config.host}/verify-mail?token=${token}">link</a> to verify your account!!! Thanks!!!</p>`;
var sent = mail.send(req.body.email, subject, content); var sent = mail.send(req.body.email, subject, content);
if (sent != "0") { if (sent != "0") {
var data = { var data = {

View file

@ -4,8 +4,6 @@ var registerlogin = require("./registerlogin");
let controller = require("../controllers/controllers"); let controller = require("../controllers/controllers");
router.get("/verify-email", registerlogin.verifyemail);
router.get('/', (_req, res) => { router.get('/', (_req, res) => {
res.render('pages/index'); res.render('pages/index');
}) })
@ -48,6 +46,16 @@ router.route('/login')
}); });
}) })
router.get('/verify-mail', (req, res) => {
controller.verify_mail(req.params.token).then(data => {
if (data == 200) {
res.render("pages/register-verification-success");
} else {
res.render("pages/index");
}
})
})
router.get('/forgot-password', (_req, res) => { router.get('/forgot-password', (_req, res) => {
res.render('pages/forgot-password'); res.render('pages/forgot-password');
}) })