updated the controller

This commit is contained in:
ROSHAN GARG 2024-09-17 17:29:41 +05:30
parent a64da15794
commit 56a3a9fecc
4 changed files with 7 additions and 5 deletions

View File

@ -12,6 +12,7 @@ export const isAuthenticatedRD = async (req, res, next) => {
});
}
const getToken = req.headers;
console.log(getToken);
// console.log(getToken);
//remove Bearer from token
const fronttoken = getToken.authorization.slice(7);
@ -23,8 +24,8 @@ export const isAuthenticatedRD = async (req, res, next) => {
message: "incorrect token",
});
}
// console.log(frontdecoded);
const fuser = await RetailDistributor.findById(frontdecoded.id);
console.log(frontdecoded);
const fuser = await RetailDistributor.findById(frontdecoded._id);
// console.log(fuser);
req.user = fuser;

View File

@ -3,6 +3,7 @@ import { Notification } from "./notificationModal.js";
export const getNotification = async (req, res) => {
try {
// Ensure req.user._id is defined and valid
console.log("req came here ");
if (!req.user || !req.user._id) {
return res.status(400).json({ return_message: "Invalid user ID" });
}
@ -18,7 +19,7 @@ export const getNotification = async (req, res) => {
.json({ return_message: "Fetched notifications", notifications });
}
return res.status(404).json({ return_message: "No notifications found" });
return res.status(402).json({ return_message: "No notifications found" });
} catch (error) {
return res
.status(500)

View File

@ -124,6 +124,6 @@ router
router.route("/user/password/update").put(isAuthenticatedUser, updatePassword);
router.route("/user/update/profile").put(isAuthenticatedUser, updateProfile);
router.route("/user/fcm-token", isAuthenticatedUser, saveFCMTokenForUser);
router.route("/user/fcm-token").post(isAuthenticatedUser, saveFCMTokenForUser);
export default router;