From 161b615e3caded1fcda81864673c1a9305945826 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 29 Oct 2024 07:09:54 +0000
Subject: [PATCH 1/4] docs(contributor): contrib-readme-action has updated
readme
---
README.md | 128 +++++++++++++++---------------------------------------
1 file changed, 34 insertions(+), 94 deletions(-)
diff --git a/README.md b/README.md
index 3e140ce..62862ae 100644
--- a/README.md
+++ b/README.md
@@ -259,20 +259,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Arindam
-
-
-
-
- Aryan Ramesh Jain
-
- |
-
-
-
-
- Haseeb Zaki
-
- |
@@ -280,8 +266,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
alolika bhowmik
|
-
-
@@ -296,6 +280,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Mahera Nayan
|
+
+
@@ -310,22 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Tyarla Shirisha
|
-
-
-
-
- meghanakn22
-
- |
-
-
-
-
- Vinay Anand Lodhi
-
- |
-
-
@@ -341,17 +311,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
-
- Suhas Koheda
-
- |
-
-
-
+
+
- Suman Bhadra
+ Haseeb Zaki
|
@@ -361,20 +324,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Sawan kushwah
|
+
+
-
-
+
+
- PavanTeja2005
+ Suhas Koheda
|
-
-
-
-
+
+
- Sajal Batra
+ Jay shah
|
@@ -385,10 +348,17 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
+
+
- Jay shah
+ Sajal Batra
+
+ |
+
+
+
+
+ PavanTeja2005
|
@@ -398,6 +368,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Abhijit Motekar
|
+
+
@@ -405,6 +377,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Navneet Dadhich
|
+
+
+
+
+ Vinay Anand Lodhi
+
+ |
@@ -412,8 +391,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Vishal Lade
|
-
-
@@ -435,13 +412,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Aditya Bakshi
|
-
-
-
-
- vaishnavipal1869
-
- |
+
+
@@ -456,8 +428,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Sushree Manaswini Biswal
|
-
-
@@ -472,13 +442,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Shiva Bajpai
|
-
-
-
-
- Pushpa Vishwakarma
-
- |
@@ -486,13 +449,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
MANI
|
-
-
-
-
- K N Meghana
-
- |
@@ -546,13 +502,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
-
-
- Nikhil More
-
- |
@@ -574,13 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Jai Dhingra
|
-
-
-
-
- Harjas Singh
-
- |
@@ -588,8 +530,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Dev Mishra
|
-
-
From 4704cdde7035f2bcc1b3e0598c5f12d7750b3538 Mon Sep 17 00:00:00 2001
From: haseebzaki-07
Date: Tue, 29 Oct 2024 13:25:24 +0530
Subject: [PATCH 2/4] add event verification
---
backend/controller/customer.controller.js | 1 -
backend/middlewares/authCustomer.js | 48 ++++++++++++++++-------
backend/routes/eventRouter.js | 7 ++--
frontend/src/components/Pages/Event.jsx | 16 +++++++-
4 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/backend/controller/customer.controller.js b/backend/controller/customer.controller.js
index 73c25ce..aa9b54d 100644
--- a/backend/controller/customer.controller.js
+++ b/backend/controller/customer.controller.js
@@ -123,7 +123,6 @@ async function loginCustomer(req, res) {
process.env.JWT_SECRET,
{ expiresIn: "1h" } // Expires in 1 hour
);
-
res.json({
message: "Login successful",
token,
diff --git a/backend/middlewares/authCustomer.js b/backend/middlewares/authCustomer.js
index eb17509..69d1032 100644
--- a/backend/middlewares/authCustomer.js
+++ b/backend/middlewares/authCustomer.js
@@ -1,24 +1,42 @@
const jwt = require("jsonwebtoken");
const logger = require("../config/logger");
const config = require("../config/secret");
+const Customer = require("../models/customer.model");
+ // Assuming the Customer model is located here
-const authenticateCustomer = (req, res, next) => {
+const authenticateCustomer = async (req, res, next) => {
const token = req.header("Authorization")?.split(" ")[1]; // Expecting "Bearer "
- if (token) {
- jwt.verify(token, config.JWT_SECRET, (err, user) => {
- if (err) {
- if (err.name === "TokenExpiredError") {
- return res.status(401).json({ message: "Token expired" });
- }
- return res.status(403).json({ message: "Invalid token" });
- }
- req.user = user;
- logger.info(`Customer authenticated: ${JSON.stringify(user.username)}`);
- next();
- });
- } else {
- res.sendStatus(401); // Unauthorized
+ if (!token) {
+ return res.status(401).json({ message: "Authorization token is missing" });
+ }
+
+ try {
+ // Verify token
+ const decoded = jwt.verify(token, config.JWT_SECRET);
+
+ // Retrieve user from database to check verification status
+ const user = await Customer.findById(decoded.sub);
+
+ if (!user) {
+ return res.status(404).json({ message: "User not found" });
+ }
+
+ if (!user.isVerified) {
+ return res.status(403).json({ message: "Account not verified" });
+ }
+
+ // If verified, attach user to request and proceed
+ req.user = user;
+ logger.info(`Customer authenticated: ${user.name}`);
+ next();
+
+ } catch (err) {
+ if (err.name === "TokenExpiredError") {
+ return res.status(401).json({ message: "Token expired" });
+ }
+ logger.error("Token verification failed:", err);
+ return res.status(403).json({ message: "Invalid token" });
}
};
diff --git a/backend/routes/eventRouter.js b/backend/routes/eventRouter.js
index 7cdcece..1cd9d77 100644
--- a/backend/routes/eventRouter.js
+++ b/backend/routes/eventRouter.js
@@ -5,6 +5,7 @@ const {
getEvents,
deleteEvent,
} = require("../controller/event.controller");
+const authenticateCustomer = require("../middlewares/authCustomer");
const router = express.Router();
@@ -24,8 +25,8 @@ router.get("/", async (req, res) => {
res.status(500).json({ error: "Internal server error" });
}
});
-router.post("/create", createEvent);
-router.get("/all", getEvents);
-router.get("/delete", deleteEvent);
+router.post("/create",authenticateCustomer, createEvent);
+router.get("/all",authenticateCustomer, getEvents);
+router.get("/delete",authenticateCustomer, deleteEvent);
module.exports = router;
diff --git a/frontend/src/components/Pages/Event.jsx b/frontend/src/components/Pages/Event.jsx
index d60a3fc..db47e4d 100644
--- a/frontend/src/components/Pages/Event.jsx
+++ b/frontend/src/components/Pages/Event.jsx
@@ -14,6 +14,8 @@ import game from '../../assets/Boardgames/carrom.gif';
import spin from '../../assets/Boardgames/spin.gif';
import MainHOC from '../MainHOC';
const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+import { useNavigate } from 'react-router-dom';
+import Cookies from 'js-cookie';
const months = [
'January',
'February',
@@ -31,6 +33,18 @@ const months = [
function Event() {
const [events, setEvents] = useState([]);
const [error, setError] = useState(null);
+ const navigate = useNavigate();
+
+
+
+ const handleRegisterClick = () => {
+ const isAuthenticated = Boolean(Cookies.get('authToken'));
+
+ if (!isAuthenticated) {
+ alert("Please sign in to register for the event.");
+ navigate('/login');
+ }
+ };
useEffect(() => {
const fetchData = async () => {
try {
@@ -183,7 +197,7 @@ function Event() {
))}
-
From dc62e330ad80b068c58e86928d0882e96d36ae99 Mon Sep 17 00:00:00 2001
From: Haseeb Zaki <147314463+haseebzaki-07@users.noreply.github.com>
Date: Tue, 29 Oct 2024 15:46:21 +0530
Subject: [PATCH 3/4] Update README.md
---
README.md | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 8400f15..75e55ca 100644
--- a/README.md
+++ b/README.md
@@ -367,14 +367,7 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Vishnu Prasad Korada
|
-
-
-
-
-
- Jay shah
-
- |
+
From 1554bd1fc7302ff64c09dc9c21d6c80523ee3d6a Mon Sep 17 00:00:00 2001
From: Haseeb Zaki <147314463+haseebzaki-07@users.noreply.github.com>
Date: Tue, 29 Oct 2024 15:48:25 +0530
Subject: [PATCH 4/4] Update README.md
---
README.md | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 75e55ca..59f11d7 100644
--- a/README.md
+++ b/README.md
@@ -368,13 +368,7 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
|
-
-
-
-
- PavanTeja2005
-
- |
+
|