diff --git a/README.md b/README.md
index 27c3566..379e739 100644
--- a/README.md
+++ b/README.md
@@ -11,13 +11,13 @@ Milan is a hub to **connect** NGOs, Charities, and the world to **collaborate**
-
+
@@ -32,7 +32,7 @@ Milan is a hub to **connect** NGOs, Charities, and the world to **collaborate**
-
+
diff --git a/routes/club/Club.js b/routes/club/Club.js
index 34a325c..07e03d4 100644
--- a/routes/club/Club.js
+++ b/routes/club/Club.js
@@ -1,7 +1,10 @@
+/* eslint-disable no-unused-vars */
const express = require("express");
const User = require("../../schema/user/UserSchema");
const { STATUSCODE, STATUSMESSAGE } = require("../../static/Status");
const router = express.Router();
+const jwt = require("jsonwebtoken");
+const UserSchema = require("../../schema/user/UserSchema");
router.get("/", async (req, res) => {
try {
@@ -28,4 +31,33 @@ router.get("/", async (req, res) => {
}
});
+router.get("/dashboard", async (req, res) => {
+ try {
+ const token = req.cookies.Token;
+
+ if (!token) {
+ return res
+ .status(STATUSCODE.FORBIDDEN)
+ .json({ message: STATUSMESSAGE.FORBIDDEN });
+ }
+
+ const { User } = jwt.verify(token, process.env.JWT_SECRET);
+ const data = await UserSchema.findOne({ email: User.id });
+
+ if (!data)
+ return res
+ .status(STATUSCODE.NOT_FOUND)
+ .json({ message: STATUSMESSAGE.DASHBOARD_FETCH_FAILED });
+
+ const { password, _id, __v, ...dataWithoutSensitiveInfo } = data.toObject();
+ const dashboardData = { ...dataWithoutSensitiveInfo };
+
+ return res.status(STATUSCODE.OK).json(dashboardData);
+ } catch (error) {
+ res
+ .status(STATUSCODE.INTERNAL_SERVER_ERROR)
+ .json({ message: STATUSMESSAGE.INTERNAL_SERVER_ERROR });
+ }
+});
+
module.exports = router;
diff --git a/static/Status.js b/static/Status.js
index 838860e..96d2b56 100644
--- a/static/Status.js
+++ b/static/Status.js
@@ -33,6 +33,7 @@ const STATUSMESSAGE = {
SIGNUP_SUCCESS: "Signed up !",
SIGNUP_FAILED: "Signup failed !",
USER_NOT_FOUND: "User not found !",
+ DASHBOARD_FETCH_FAILED: "Failed to fetch dashboard data !",
USER_ALREADY_EXISTS: "User already exists, please Login !",
INVALID_CREDENTIALS: "Invalid credentials !",
INTERNAL_SERVER_ERROR: "Internal server error, try again later !",