diff --git a/controllers/controllers.js b/controllers/controllers.js index b003643..cdec7b9 100644 --- a/controllers/controllers.js +++ b/controllers/controllers.js @@ -56,9 +56,16 @@ function login(email, password, ua, ip) { .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 = { getProducts, getProduct, register, - login + login, + verify_mail } \ No newline at end of file diff --git a/routes/api.js b/routes/api.js index 6d34ee6..47aeda4 100644 --- a/routes/api.js +++ b/routes/api.js @@ -76,7 +76,7 @@ router.post('/register', async (req, res) => { var token = randtoken.generate(20); if (result[0].verify == 0) { let subject = "Account Verification - Nekoya"; - let content = `
Hello!!! Please click this link link to verify your account!!! Thanks!!!
`; + let content = `Hello!!! Please click this link link to verify your account!!! Thanks!!!
`; var sent = mail.send(req.body.email, subject, content); if (sent != "0") { var data = { diff --git a/routes/index.js b/routes/index.js index b3a1097..a1ffb02 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,8 +4,6 @@ var registerlogin = require("./registerlogin"); let controller = require("../controllers/controllers"); -router.get("/verify-email", registerlogin.verifyemail); - router.get('/', (_req, res) => { 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) => { res.render('pages/forgot-password'); })