Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
mudroljub committed Dec 16, 2024
1 parent f2b5bc8 commit 700fbd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/controllers/AuthController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nodemailer from 'nodemailer'
import UserService from '../services/UserService.js'
import AuthService from '../services/AuthService.js'

Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/services/AuthService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const createToken = (id, privilege) => {
return token
}

const sendEmail = email => {
const sendEmail = user => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: process.env.EMAIL_PASSWORD
}
})

const token = createToken(user.id, user.privilege)
const mailOptions = {
from: '[email protected]',
to: email,
to: user.email,
subject: 'Programming Quotes - Verify Email',
text: 'That was easy!' // TODO: token link
text: token
}

return transporter.sendMail(mailOptions)
Expand Down

0 comments on commit 700fbd2

Please sign in to comment.