From 700fbd2819eb984952515c918108cfac0fb430ea Mon Sep 17 00:00:00 2001 From: Damjan Pavlica Date: Mon, 16 Dec 2024 23:17:54 +0100 Subject: [PATCH] m --- src/controllers/AuthController.js | 3 +-- src/services/AuthService.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/controllers/AuthController.js b/src/controllers/AuthController.js index 1372728..92795f8 100644 --- a/src/controllers/AuthController.js +++ b/src/controllers/AuthController.js @@ -1,4 +1,3 @@ -import nodemailer from 'nodemailer' import UserService from '../services/UserService.js' import AuthService from '../services/AuthService.js' @@ -19,7 +18,7 @@ const sendEmail = async(req, res) => { const user = await UserService.getById(req.user.id) try { - const info = AuthService.sendEmail(user.email) + const info = AuthService.sendEmail(user) res.status(200).send(`Email sent: ${info.response}`) } catch (error) { console.error(error) diff --git a/src/services/AuthService.js b/src/services/AuthService.js index e9d9afb..c743928 100644 --- a/src/services/AuthService.js +++ b/src/services/AuthService.js @@ -9,7 +9,7 @@ const createToken = (id, privilege) => { return token } -const sendEmail = email => { +const sendEmail = user => { const transporter = nodemailer.createTransport({ service: 'gmail', auth: { @@ -17,12 +17,12 @@ const sendEmail = email => { pass: process.env.EMAIL_PASSWORD } }) - + const token = createToken(user.id, user.privilege) const mailOptions = { from: 'mudroljub@gmail.com', - to: email, + to: user.email, subject: 'Programming Quotes - Verify Email', - text: 'That was easy!' // TODO: token link + text: token } return transporter.sendMail(mailOptions)