가입시 이메일로 가입자 받는 부분 삭제
This commit is contained in:
parent
2bb0a3374b
commit
fa0562117d
4
.env
4
.env
@ -2,8 +2,8 @@
|
|||||||
MONGODB_URI="mongodb://siinand:Qlenfrl1199424!@101.79.10.128:27017/local"
|
MONGODB_URI="mongodb://siinand:Qlenfrl1199424!@101.79.10.128:27017/local"
|
||||||
# MONGODB_URI="mongodb://localhost:27017/local"
|
# MONGODB_URI="mongodb://localhost:27017/local"
|
||||||
PORT=5100
|
PORT=5100
|
||||||
# RECEIVING_EMAIL=
|
RECEIVING_EMAIL=siinand@gmail.com
|
||||||
# EMAIL_PASSWORD=
|
EMAIL_PASSWORD=Qlenfrl1199424!
|
||||||
# SHIPPING_FEE=
|
# SHIPPING_FEE=
|
||||||
BASE_CURRENCY=KRW
|
BASE_CURRENCY=KRW
|
||||||
# STRIPE_SECRET_KEY=
|
# STRIPE_SECRET_KEY=
|
||||||
|
@ -1,13 +1,100 @@
|
|||||||
// controllers/userController.js
|
// controllers/userController.js
|
||||||
const User = require('../models/User');
|
const User = require("../models/User");
|
||||||
const Products = require('../models/Product');
|
const Products = require("../models/Product");
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require("jsonwebtoken");
|
||||||
const bcrypt = require('bcrypt');
|
const bcrypt = require("bcrypt");
|
||||||
const otpGenerator = require('otp-generator');
|
const otpGenerator = require("otp-generator");
|
||||||
const nodemailer = require('nodemailer');
|
const nodemailer = require("nodemailer");
|
||||||
const fs = require('fs');
|
const fs = require("fs");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
const { getUser } = require('../config/getUser');
|
const { getUser } = require("../config/getUser");
|
||||||
|
// const registerUser = async (req, res) => {
|
||||||
|
// try {
|
||||||
|
// // Create user in the database
|
||||||
|
// const request = req.body; // No need to use await here
|
||||||
|
// const UserCount = await User.countDocuments();
|
||||||
|
// const existingUser = await User.findOne({ email: request.email });
|
||||||
|
|
||||||
|
// if (existingUser) {
|
||||||
|
// return res.status(400).json({
|
||||||
|
// UserCount,
|
||||||
|
// success: false,
|
||||||
|
// message: 'User With This Email Already Exists',
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const otp = otpGenerator.generate(6, {
|
||||||
|
// upperCaseAlphabets: false,
|
||||||
|
// specialChars: false,
|
||||||
|
// lowerCaseAlphabets: false,
|
||||||
|
// digits: true,
|
||||||
|
// });
|
||||||
|
// // Create user with the generated OTP
|
||||||
|
// const user = await User.create({
|
||||||
|
// ...request,
|
||||||
|
// otp,
|
||||||
|
// role: Boolean(UserCount) ? request.role || 'user' : 'super admin',
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Generate JWT token
|
||||||
|
// const token = jwt.sign(
|
||||||
|
// {
|
||||||
|
// _id: user._id,
|
||||||
|
// // email: user.email,
|
||||||
|
// },
|
||||||
|
// process.env.JWT_SECRET,
|
||||||
|
// {
|
||||||
|
// expiresIn: '7d',
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// // Path to the HTML file
|
||||||
|
// const htmlFilePath = path.join(
|
||||||
|
// process.cwd(),
|
||||||
|
// 'src/email-templates',
|
||||||
|
// 'otp.html'
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // Read HTML file content
|
||||||
|
// let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
||||||
|
|
||||||
|
// // Replace the placeholder with the OTP and user email
|
||||||
|
// htmlContent = htmlContent.replace(/<h1>[\s\d]*<\/h1>/g, `<h1>${otp}</h1>`);
|
||||||
|
// htmlContent = htmlContent.replace(/usingyourmail@gmail\.com/g, user.email);
|
||||||
|
|
||||||
|
// // Create nodemailer transporter
|
||||||
|
// let transporter = nodemailer.createTransport({
|
||||||
|
// service: 'gmail',
|
||||||
|
// auth: {
|
||||||
|
// user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
|
// pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Email options
|
||||||
|
// let mailOptions = {
|
||||||
|
// from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
|
// to: user.email, // User's email
|
||||||
|
// subject: 'Verify your email',
|
||||||
|
// html: htmlContent, // HTML content with OTP and user email
|
||||||
|
// };
|
||||||
|
|
||||||
|
// // Send email
|
||||||
|
// await transporter.sendMail(mailOptions);
|
||||||
|
// res.status(201).json({
|
||||||
|
// success: true,
|
||||||
|
// message: 'Created User Successfully',
|
||||||
|
// otp,
|
||||||
|
// token,
|
||||||
|
// user,
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// res.status(500).json({
|
||||||
|
// message: error.message,
|
||||||
|
// status: 500,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
const registerUser = async (req, res) => {
|
const registerUser = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// Create user in the database
|
// Create user in the database
|
||||||
@ -19,7 +106,7 @@ const registerUser = async (req, res) => {
|
|||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
UserCount,
|
UserCount,
|
||||||
success: false,
|
success: false,
|
||||||
message: 'User With This Email Already Exists',
|
message: "User With This Email Already Exists",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,60 +116,28 @@ const registerUser = async (req, res) => {
|
|||||||
lowerCaseAlphabets: false,
|
lowerCaseAlphabets: false,
|
||||||
digits: true,
|
digits: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create user with the generated OTP
|
// Create user with the generated OTP
|
||||||
const user = await User.create({
|
const user = await User.create({
|
||||||
...request,
|
...request,
|
||||||
otp,
|
otp,
|
||||||
role: Boolean(UserCount) ? request.role || 'user' : 'super admin',
|
role: Boolean(UserCount) ? request.role || "user" : "super admin",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate JWT token
|
// Generate JWT token
|
||||||
const token = jwt.sign(
|
const token = jwt.sign(
|
||||||
{
|
{
|
||||||
_id: user._id,
|
_id: user._id,
|
||||||
// email: user.email,
|
|
||||||
},
|
},
|
||||||
process.env.JWT_SECRET,
|
process.env.JWT_SECRET,
|
||||||
{
|
{
|
||||||
expiresIn: '7d',
|
expiresIn: "7d",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Path to the HTML file
|
|
||||||
const htmlFilePath = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
'src/email-templates',
|
|
||||||
'otp.html'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Read HTML file content
|
|
||||||
let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
|
||||||
|
|
||||||
// Replace the placeholder with the OTP and user email
|
|
||||||
htmlContent = htmlContent.replace(/<h1>[\s\d]*<\/h1>/g, `<h1>${otp}</h1>`);
|
|
||||||
htmlContent = htmlContent.replace(/usingyourmail@gmail\.com/g, user.email);
|
|
||||||
|
|
||||||
// Create nodemailer transporter
|
|
||||||
let transporter = nodemailer.createTransport({
|
|
||||||
service: 'gmail',
|
|
||||||
auth: {
|
|
||||||
user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
|
||||||
pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Email options
|
|
||||||
let mailOptions = {
|
|
||||||
from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
|
||||||
to: user.email, // User's email
|
|
||||||
subject: 'Verify your email',
|
|
||||||
html: htmlContent, // HTML content with OTP and user email
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send email
|
|
||||||
await transporter.sendMail(mailOptions);
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Created User Successfully',
|
message: "Created User Successfully",
|
||||||
otp,
|
otp,
|
||||||
token,
|
token,
|
||||||
user,
|
user,
|
||||||
@ -94,27 +149,31 @@ const registerUser = async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loginUser = async (req, res) => {
|
const loginUser = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { email, password } = await req.body;
|
const { email, password } = await req.body;
|
||||||
const user = await User.findOne({ email }).select('+password');
|
const user = await User.findOne({ email }).select("+password");
|
||||||
|
|
||||||
if (user.isVerified === false) {
|
if (user.isVerified === false) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: '탈퇴한 회원입니다. 관리자에게 문의하세요' });
|
.json({
|
||||||
|
success: false,
|
||||||
|
message: "탈퇴한 회원입니다. 관리자에게 문의하세요",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: 'User Not Found' });
|
.json({ success: false, message: "User Not Found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.password) {
|
if (!user.password) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: 'User Password Not Found' });
|
.json({ success: false, message: "User Password Not Found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const isPasswordMatch = await bcrypt.compare(password, user.password);
|
const isPasswordMatch = await bcrypt.compare(password, user.password);
|
||||||
@ -122,7 +181,7 @@ const loginUser = async (req, res) => {
|
|||||||
if (!isPasswordMatch) {
|
if (!isPasswordMatch) {
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
.json({ success: false, message: 'Incorrect Password' });
|
.json({ success: false, message: "Incorrect Password" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = jwt.sign(
|
const token = jwt.sign(
|
||||||
@ -132,7 +191,7 @@ const loginUser = async (req, res) => {
|
|||||||
},
|
},
|
||||||
process.env.JWT_SECRET,
|
process.env.JWT_SECRET,
|
||||||
{
|
{
|
||||||
expiresIn: '7d',
|
expiresIn: "7d",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -144,21 +203,21 @@ const loginUser = async (req, res) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'productreviews',
|
from: "productreviews",
|
||||||
localField: 'productreviews',
|
localField: "productreviews",
|
||||||
foreignField: '_id',
|
foreignField: "_id",
|
||||||
as: 'productreviews',
|
as: "productreviews",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$addFields: {
|
$addFields: {
|
||||||
averageRating: { $avg: '$productreviews.rating' },
|
averageRating: { $avg: "$productreviews.rating" },
|
||||||
image: { $arrayElemAt: ['$images', 0] },
|
image: { $arrayElemAt: ["$images", 0] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
image: { url: '$image.url', blurDataURL: '$image.blurDataURL' },
|
image: { url: "$image.url", blurDataURL: "$image.blurDataURL" },
|
||||||
name: 1,
|
name: 1,
|
||||||
slug: 1,
|
slug: 1,
|
||||||
colors: 1,
|
colors: 1,
|
||||||
@ -176,7 +235,7 @@ const loginUser = async (req, res) => {
|
|||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Login Successfully',
|
message: "Login Successfully",
|
||||||
token,
|
token,
|
||||||
user: {
|
user: {
|
||||||
_id: user._id,
|
_id: user._id,
|
||||||
@ -209,11 +268,11 @@ const forgetPassword = async (req, res) => {
|
|||||||
if (!user) {
|
if (!user) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: 'User Not Found ' });
|
.json({ success: false, message: "User Not Found " });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = jwt.sign({ _id: user._id }, process.env.JWT_SECRET, {
|
const token = jwt.sign({ _id: user._id }, process.env.JWT_SECRET, {
|
||||||
expiresIn: '7d',
|
expiresIn: "7d",
|
||||||
});
|
});
|
||||||
// Constructing the link with the token
|
// Constructing the link with the token
|
||||||
const resetPasswordLink = `${request.origin}/auth/reset-password/${token}`;
|
const resetPasswordLink = `${request.origin}/auth/reset-password/${token}`;
|
||||||
@ -221,12 +280,12 @@ const forgetPassword = async (req, res) => {
|
|||||||
// Path to the HTML file
|
// Path to the HTML file
|
||||||
const htmlFilePath = path.join(
|
const htmlFilePath = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'src/email-templates',
|
"src/email-templates",
|
||||||
'forget.html'
|
"forget.html"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read HTML file content
|
// Read HTML file content
|
||||||
let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
let htmlContent = fs.readFileSync(htmlFilePath, "utf8");
|
||||||
|
|
||||||
// Replace the href attribute of the <a> tag with the reset password link
|
// Replace the href attribute of the <a> tag with the reset password link
|
||||||
// htmlContent = htmlContent.replace(
|
// htmlContent = htmlContent.replace(
|
||||||
@ -239,7 +298,7 @@ const forgetPassword = async (req, res) => {
|
|||||||
);
|
);
|
||||||
// Create nodemailer transporter
|
// Create nodemailer transporter
|
||||||
let transporter = nodemailer.createTransport({
|
let transporter = nodemailer.createTransport({
|
||||||
service: 'gmail',
|
service: "gmail",
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
||||||
@ -250,7 +309,7 @@ const forgetPassword = async (req, res) => {
|
|||||||
let mailOptions = {
|
let mailOptions = {
|
||||||
from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
to: user.email, // User's email
|
to: user.email, // User's email
|
||||||
subject: 'Verify your email',
|
subject: "Verify your email",
|
||||||
html: htmlContent, // HTML content with OTP and user email
|
html: htmlContent, // HTML content with OTP and user email
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -259,7 +318,7 @@ const forgetPassword = async (req, res) => {
|
|||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Forgot Password Email Sent Successfully.',
|
message: "Forgot Password Email Sent Successfully.",
|
||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -278,24 +337,24 @@ const resetPassword = async (req, res) => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Invalid Or Expired Token. Please Request A New One.',
|
message: "Invalid Or Expired Token. Please Request A New One.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the user by ID from the token
|
// Find the user by ID from the token
|
||||||
const user = await User.findById(decoded._id).select('password');
|
const user = await User.findById(decoded._id).select("password");
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(404).json({
|
return res.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'User Not Found ',
|
message: "User Not Found ",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!newPassword || !user.password) {
|
if (!newPassword || !user.password) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
message:
|
message:
|
||||||
'Invalid Data. Both NewPassword And User Password Are Required.',
|
"Invalid Data. Both NewPassword And User Password Are Required.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +363,7 @@ const resetPassword = async (req, res) => {
|
|||||||
if (isSamePassword) {
|
if (isSamePassword) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'New Password Must Be Different From The Old Password.',
|
message: "New Password Must Be Different From The Old Password.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Update the user's password
|
// Update the user's password
|
||||||
@ -316,7 +375,7 @@ const resetPassword = async (req, res) => {
|
|||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Password Updated Successfully.',
|
message: "Password Updated Successfully.",
|
||||||
user,
|
user,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -326,50 +385,50 @@ const resetPassword = async (req, res) => {
|
|||||||
const verifyOtp = async (req, res) => {
|
const verifyOtp = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { otp } = req.body;
|
const { otp } = req.body;
|
||||||
const user = await getUser(req, res, 'not-verified');
|
const user = await getUser(req, res, "not-verified");
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: 'User Not Found' });
|
.json({ success: false, message: "User Not Found" });
|
||||||
}
|
}
|
||||||
// Check if OTP has already been verified
|
// Check if OTP has already been verified
|
||||||
if (user.isVerified) {
|
if (user.isVerified) {
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
.json({ success: false, message: 'OTP Has Already Been Verified' });
|
.json({ success: false, message: "OTP Has Already Been Verified" });
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = '';
|
let message = "";
|
||||||
// Verify the OTP
|
// Verify the OTP
|
||||||
if (otp === user.otp) {
|
if (otp === user.otp) {
|
||||||
user.isVerified = true;
|
user.isVerified = true;
|
||||||
await user.save();
|
await user.save();
|
||||||
message = 'OTP Verified Successfully';
|
message = "OTP Verified Successfully";
|
||||||
return res.status(200).json({ success: true, message });
|
return res.status(200).json({ success: true, message });
|
||||||
} else {
|
} else {
|
||||||
message = 'Invalid OTP';
|
message = "Invalid OTP";
|
||||||
return res.status(400).json({ success: false, message });
|
return res.status(400).json({ success: false, message });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res
|
return res
|
||||||
.status(500)
|
.status(500)
|
||||||
.json({ success: false, message: 'Internal Server Error' });
|
.json({ success: false, message: "Internal Server Error" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resendOtp = async (req, res) => {
|
const resendOtp = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const user = await getUser(req, res, 'not-verified');
|
const user = await getUser(req, res, "not-verified");
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ success: false, message: 'User Not Found' });
|
.json({ success: false, message: "User Not Found" });
|
||||||
}
|
}
|
||||||
if (user.isVerified) {
|
if (user.isVerified) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'OTP Has Already Been Verified',
|
message: "OTP Has Already Been Verified",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Generate new OTP
|
// Generate new OTP
|
||||||
@ -387,12 +446,12 @@ const resendOtp = async (req, res) => {
|
|||||||
// Path to the HTML file
|
// Path to the HTML file
|
||||||
const htmlFilePath = path.join(
|
const htmlFilePath = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'src/email-templates',
|
"src/email-templates",
|
||||||
'otp.html'
|
"otp.html"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read HTML file content
|
// Read HTML file content
|
||||||
let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
let htmlContent = fs.readFileSync(htmlFilePath, "utf8");
|
||||||
|
|
||||||
// Replace the placeholder with the OTP and user email
|
// Replace the placeholder with the OTP and user email
|
||||||
htmlContent = htmlContent.replace(/<h1>[\s\d]*<\/h1>/g, `<h1>${otp}</h1>`);
|
htmlContent = htmlContent.replace(/<h1>[\s\d]*<\/h1>/g, `<h1>${otp}</h1>`);
|
||||||
@ -400,7 +459,7 @@ const resendOtp = async (req, res) => {
|
|||||||
|
|
||||||
// Create nodemailer transporter
|
// Create nodemailer transporter
|
||||||
let transporter = nodemailer.createTransport({
|
let transporter = nodemailer.createTransport({
|
||||||
service: 'gmail',
|
service: "gmail",
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
user: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
pass: process.env.EMAIL_PASSWORD, // Your Gmail password
|
||||||
@ -411,7 +470,7 @@ const resendOtp = async (req, res) => {
|
|||||||
let mailOptions = {
|
let mailOptions = {
|
||||||
from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
from: process.env.RECEIVING_EMAIL, // Your Gmail email
|
||||||
to: user.email, // User's email
|
to: user.email, // User's email
|
||||||
subject: 'Verify your email',
|
subject: "Verify your email",
|
||||||
html: htmlContent, // HTML content with OTP and user email
|
html: htmlContent, // HTML content with OTP and user email
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -421,7 +480,7 @@ const resendOtp = async (req, res) => {
|
|||||||
// Return the response
|
// Return the response
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'OTP Resent Successfully',
|
message: "OTP Resent Successfully",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res.status(400).json({ success: false, message: error.message });
|
return res.status(400).json({ success: false, message: error.message });
|
||||||
|
Loading…
Reference in New Issue
Block a user