This commit is contained in:
omkieit 2024-09-07 19:38:04 +05:30
parent a6d1abee9c
commit 05f7653597
1 changed files with 2 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import dotenv from "dotenv";
import UserModal from "../models/user.js"; import UserModal from "../models/user.js";
import bcrypt from "bcryptjs"; import bcrypt from "bcryptjs";
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import { sendEmail } from "../utils/sendEmail.js";
dotenv.config(); dotenv.config();
const secret = process.env.SECRET_KEY; const secret = process.env.SECRET_KEY;
@ -37,12 +38,11 @@ export const signup = async (req, res) => {
// Save the token in the user's tokens array // Save the token in the user's tokens array
result.tokens.push({ token }); result.tokens.push({ token });
// Save the user
await result.save(); await result.save();
// console.log("ss", result)
const url = `Click on the link ${process.env.RETURN_URL}/users/${result._id}/verify/${token}`; const url = `Click on the link ${process.env.RETURN_URL}/users/${result._id}/verify/${token}`;
await sendEmail(result.email, "Verify Email", url); await sendEmail(result.email, "Verify Email", url);
console.log("url", url);
// Send the user info and token back to the client // Send the user info and token back to the client
res.status(201).json({ result, token }); res.status(201).json({ result, token });