updated the controller
This commit is contained in:
parent
a64da15794
commit
56a3a9fecc
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -4,7 +4,7 @@ import app from "./app.js";
|
||||
import connectDatabase from "./database/db.js";
|
||||
import cloudinary from "cloudinary";
|
||||
import cron from "node-cron";
|
||||
import {updateOverdueTasks} from "./resources/Task/TaskController.js ";
|
||||
import { updateOverdueTasks } from "./resources/Task/TaskController.js ";
|
||||
// Connecting to database
|
||||
connectDatabase();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user