diff --git a/backend/src/controller/auth.js b/backend/src/controller/auth.js index 790e6be..420fef5 100644 --- a/backend/src/controller/auth.js +++ b/backend/src/controller/auth.js @@ -19,7 +19,7 @@ const usersSignInSchema = z.object({ const sendEmailVarification = async ({ userID, username, email }, res) => { try { - console.log(userID, email); + // console.log(userID, email); const otp = `${Math.floor(1000 + Math.random() * 9000)}`; const hashOtp = await bcrypt.hash(otp, 10); @@ -55,7 +55,7 @@ const sendEmailVarification = async ({ userID, username, email }, res) => { userID: userID, }, }); - console.log(isUser); + // console.log(isUser); if (isUser) { const updateUser = await prisma.userVarify.update({ @@ -68,7 +68,7 @@ const sendEmailVarification = async ({ userID, username, email }, res) => { expiresAt: Date.now() + 180000, }, }); - console.log(updateUser); + // console.log(updateUser); } else { const userdata = await prisma.userVarify.create({ data: { @@ -78,7 +78,7 @@ const sendEmailVarification = async ({ userID, username, email }, res) => { expiresAt: Date.now() + 180000, }, }); - console.log(userdata); + // console.log(userdata); } res @@ -103,10 +103,7 @@ const signup = async (req, res) => { res.json({ message: "Credentials cannot be empty" }); } const hashPass = bcrypt.hashSync(password, 10); - //here checks -------------- - var token = jwt.sign({ email: email }, process.env.SECRET_KEY, { - expiresIn: "1d", - }); + const isuser = await prisma.user.findFirst({ where: { @@ -145,7 +142,7 @@ const signup = async (req, res) => { }, }); } - console.log(newUser); + // console.log(newUser); await sendEmailVarification(newUser, res); } catch (error) { console.log(error); @@ -195,7 +192,7 @@ const varifyOtp = async (req, res) => { { userId: userID, email: email }, process.env.SECRET_KEY, { - expiresIn: 24 * 60 * 60, + expiresIn: 24 * 60 * 60 * 7, } ); const updateUser = await prisma.user.update({ @@ -229,7 +226,7 @@ const varifyOtp = async (req, res) => { }; const resendOtp = async (req, res) => { - console.log(req.body); + // console.log(req.body); try { await sendEmailVarification(req.body, res); } catch (error) { @@ -239,7 +236,7 @@ const resendOtp = async (req, res) => { const resetPassword = async (req, res) => { const { email } = req.body; - console.log(req.body); + // console.log(req.body); const user = await prisma.user.findUnique({ where: { @@ -301,7 +298,7 @@ const signin = async (req, res) => { ], }, }); - console.log(user); + // console.log(user); if (!user) { return res @@ -313,15 +310,15 @@ const signin = async (req, res) => { { userId: user.userID, email: user.email }, process.env.SECRET_KEY, { - expiresIn: 24 * 60 * 60, + expiresIn: 24 * 60 * 60 * 7, } ); - console.log(token); + // console.log(token); const hashPass = user.password; const isVarified = user.isVarified; const validPass = bcrypt.compareSync(password, hashPass); - console.log(validPass); + // console.log(validPass); if (!isVarified) { res.status(404).send({ msg: "User is not varified!" }); } diff --git a/backend/src/controller/posts.js b/backend/src/controller/posts.js index 8222ba5..8067e25 100644 --- a/backend/src/controller/posts.js +++ b/backend/src/controller/posts.js @@ -18,18 +18,18 @@ export const createPost = async (req, res) => { if (req.file) { try { url = await uploadOnCloudinary(req.file.path); - console.log("file Object = " + url); + // console.log("file Object = " + url); } catch (err) { console.log("Failed To Upload Image\n",err); const message = err.message.split(".")[0] - console.log(message) + // console.log(message) return res.status(405).json({ msg:message }) } } const parsedBody = post.safeParse(postbody); - console.log(parsedBody); + // console.log(parsedBody); if (parsedBody.error) res.status(405).json({ @@ -87,7 +87,7 @@ export const getPost = async (req, res) => { const offset = (page - 1) * limit; const roomTitle = req.query?.title; // console.log(offset, limit); - console.log(roomTitle); + // console.log(roomTitle); try { const posts = await prisma.post.findMany({ @@ -192,7 +192,7 @@ export const getHotPost = async (req, res) => { export const deletePost = async(req,res) =>{ const userId = req.userId; const id = req.body.id; - console.log(id); + // console.log(id); try{ const post = await prisma.post.findFirst({ @@ -278,8 +278,8 @@ let posts = JSON.parse(stringify(result)); return (p.privateRoom == null || p.privateRoom!=true) }) const postIds = posts.map(post => post.id); - console.log("Inside Poular") - console.log(posts); + // console.log("Inside Poular") + // console.log(posts); const upvotes = await prisma.upvote.findMany({ where: { postId: { diff --git a/backend/src/controller/search.js b/backend/src/controller/search.js index 978b15e..46ef567 100644 --- a/backend/src/controller/search.js +++ b/backend/src/controller/search.js @@ -91,7 +91,7 @@ export const getUserPosts = async (req, res) => { const offset = parseInt(req.query.offset) || (page - 1) * limit; // console.log(page, offset); const { userID, username } = req.query; - console.log(userID, username); + // console.log(userID, username); try { @@ -132,9 +132,9 @@ export const getUserComments = async (req, res) => { const page = parseInt(req.query.page) || 1; const limit = parseInt(req.query.limit) || 10; const offset = parseInt(req.query.offset) || (page - 1) * limit; - console.log(page, offset); + // console.log(page, offset); const { userID, username } = req.query; - console.log(userID); + // console.log(userID); try { @@ -166,7 +166,7 @@ export const getUserComments = async (req, res) => { const altcomments = comments.filter((cmt)=>{ return (cmt.post.room == null || cmt.post.room.privateRoom == false); }) - console.log(altcomments); + // console.log(altcomments); res.status(200).send(altcomments); diff --git a/backend/src/middlewares/verifytoken.js b/backend/src/middlewares/verifytoken.js index 2b659c3..bd298f7 100644 --- a/backend/src/middlewares/verifytoken.js +++ b/backend/src/middlewares/verifytoken.js @@ -10,8 +10,7 @@ export const verifyToken = (req, res, next) => { if (payload.email) { req.userId = payload.userId; req.email = payload.email; - console.log("Token varified"); - console.log(req?.body || "Request Not found"); + // console.log("Token varified"); next(); } else res.status(401).send({ msg: "Invalid Token" });