From 1df68f25ef02a0a985b2b647f3c138d869ff9899 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:10:38 +0000 Subject: [PATCH 1/5] docs(contributor): contrib-readme-action has updated readme --- README.md | 138 ++++++++++-------------------------------------------- 1 file changed, 25 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index d57a3ac..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 - - - haseebzaki-07 -
- Haseeb Zaki -
- - - - jainaryan04 -
- Aryan Ramesh Jain -
- alo7lika @@ -280,8 +266,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made alolika bhowmik - - Ashwinib26 @@ -296,6 +280,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mahera Nayan + + tejasbenibagde @@ -310,13 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Tyarla Shirisha - - - NilanchalaPanda -
- Nilanchal -
- Amnyadav @@ -324,20 +303,18 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Aman Yadav - - - - VinayLodhi1712 + + NilanchalaPanda
- Vinay Anand Lodhi + Nilanchal
- - meghanakn22 + + haseebzaki-07
- meghanakn22 + Haseeb Zaki
@@ -347,13 +324,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sawan kushwah - - - Sumanbhadra -
- Suman Bhadra -
- + + Suhas-Koheda @@ -368,8 +340,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jay shah - - vishnuprasad2004 @@ -377,13 +347,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishnu Prasad Korada - - - Sourabh782 -
- Sourabh Singh Rawat -
- sajalbatra @@ -405,27 +368,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Abhijit Motekar + + Navneetdadhich
Navneet Dadhich
- - - - - - CoderFleet -
- Rudransh Pratap Singh -
- - AE-Hertz + + VinayLodhi1712
- Abhinandan + Vinay Anand Lodhi
@@ -458,13 +414,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - - vaishnavipal1869 -
- vaishnavipal1869 -
- tanishirai @@ -480,28 +429,19 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - Shiva-Bajpai + + Sourabh782
- Shiva Bajpai + Sourabh Singh Rawat
- - Pushpa472 + + Shiva-Bajpai
- Pushpa Vishwakarma + Shiva Bajpai
- - - Mansi07sharma -
- Mansi Sharma -
- - - devxMani @@ -509,13 +449,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made MANI - - - meghanakn473 -
- K N Meghana -
- Ayush215mb @@ -523,6 +456,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ayush Yadav + + smog-root @@ -544,8 +479,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vaibhav-Kumar-K-R - - Syed-Farazuddin @@ -567,13 +500,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sapna Kul - - - Nikhil0-3 -
- Nikhil More -
- + + MutiatBash @@ -588,8 +516,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mohit Rana - - jaidh01 @@ -597,13 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jai Dhingra - - - harjasae2001 -
- Harjas Singh -
- mishradev1 @@ -618,13 +537,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made CHIKATLA RAKESH - - - AnushkaChouhan25 -
- Anushka Chouhan -
- AliGates915 From 7df9c259abbf58e5fa39d2720f0c3661f85d429d Mon Sep 17 00:00:00 2001 From: haseebzaki-07 Date: Tue, 29 Oct 2024 22:44:19 +0530 Subject: [PATCH 2/5] verified users --- backend/routes/eventRouter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/routes/eventRouter.js b/backend/routes/eventRouter.js index 1cd9d77..a0b3670 100644 --- a/backend/routes/eventRouter.js +++ b/backend/routes/eventRouter.js @@ -25,6 +25,7 @@ router.get("/", async (req, res) => { res.status(500).json({ error: "Internal server error" }); } }); + router.post("/create",authenticateCustomer, createEvent); router.get("/all",authenticateCustomer, getEvents); router.get("/delete",authenticateCustomer, deleteEvent); From 88e51c4ee5791d154327ffb729a5331afa258658 Mon Sep 17 00:00:00 2001 From: haseebzaki-07 Date: Tue, 29 Oct 2024 22:55:12 +0530 Subject: [PATCH 3/5] add verified users --- README.md | 143 +++++++++++++++++++----- backend/middlewares/authCustomer.js | 48 +++++--- backend/routes/eventRouter.js | 1 + frontend/src/components/Pages/Event.jsx | 14 ++- 4 files changed, 159 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 62862ae..c2ec761 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Arindam + + + haseebzaki-07 +
+ Haseeb Zaki +
+ + + + jainaryan04 +
+ Aryan Ramesh Jain +
+ alo7lika @@ -266,6 +280,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made alolika bhowmik + + Ashwinib26 @@ -280,8 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mahera Nayan - - tejasbenibagde @@ -296,6 +310,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Tyarla Shirisha + + + NilanchalaPanda +
+ Nilanchal +
+ Amnyadav @@ -303,18 +324,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Aman Yadav + + - - NilanchalaPanda + + VinayLodhi1712
- Nilanchal + Vinay Anand Lodhi
- - haseebzaki-07 + + meghanakn22
- Haseeb Zaki + meghanakn22
@@ -324,8 +347,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sawan kushwah - - + + + Sumanbhadra +
+ Suman Bhadra +
+ Suhas-Koheda @@ -340,6 +368,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jay shah + + vishnuprasad2004 @@ -347,6 +377,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishnu Prasad Korada + + + Sourabh782 +
+ Sourabh Singh Rawat +
+ sajalbatra @@ -368,8 +405,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Abhijit Motekar - - Navneetdadhich @@ -377,11 +412,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Navneet Dadhich + + - - VinayLodhi1712 + + CoderFleet
- Vinay Anand Lodhi + Rudransh Pratap Singh +
+ + + + AE-Hertz +
+ Abhinandan
@@ -414,6 +458,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made + + + vaishnavipal1869 +
+ vaishnavipal1869 +
+ tanishirai @@ -429,19 +480,28 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - Sourabh782 + + Shiva-Bajpai
- Sourabh Singh Rawat + Shiva Bajpai
- - Shiva-Bajpai + + Pushpa472
- Shiva Bajpai + Pushpa Vishwakarma
+ + + Mansi07sharma +
+ Mansi Sharma +
+ + + devxMani @@ -449,6 +509,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made MANI + + + meghanakn473 +
+ K N Meghana +
+ Ayush215mb @@ -456,8 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ayush Yadav - - smog-root @@ -479,6 +544,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vaibhav-Kumar-K-R + + Syed-Farazuddin @@ -500,8 +567,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sapna Kul - - + + + Nikhil0-3 +
+ Nikhil More +
+ MutiatBash @@ -516,6 +588,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mohit Rana + + jaidh01 @@ -523,6 +597,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jai Dhingra + + + harjasae2001 +
+ Harjas Singh +
+ mishradev1 @@ -537,6 +618,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made CHIKATLA RAKESH + + + AnushkaChouhan25 +
+ Anushka Chouhan +
+ AliGates915 @@ -600,7 +688,4 @@ Stay updated and engage with our community on social media: - [LinkedIn](https://www.linkedin.com/in/ramakrushna-biswal/) - [Email](mailto:ramakrushnabunty@gmail.com) -We are always here to help you! Don’t hesitate to connect with us and be part of the PlayCafe journey. - - - +We are always here to help you! Don’t hesitate to connect with us and be part of the PlayCafe journey. \ No newline at end of file diff --git a/backend/middlewares/authCustomer.js b/backend/middlewares/authCustomer.js index eb17509..b65b508 100644 --- a/backend/middlewares/authCustomer.js +++ b/backend/middlewares/authCustomer.js @@ -1,24 +1,38 @@ const jwt = require("jsonwebtoken"); const logger = require("../config/logger"); const config = require("../config/secret"); +const Customer = require("../models/customer.model"); -const authenticateCustomer = (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 + +const authenticateCustomer = async (req, res, next) => { + const token = req.header("Authorization")?.split(" ")[1]; + + if (!token) { + return res.status(401).json({ message: "Authorization token is missing" }); + } + + try { + const decoded = jwt.verify(token, config.JWT_SECRET); + + 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" }); + } + + 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 c025b10..a6e7c1d 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(); diff --git a/frontend/src/components/Pages/Event.jsx b/frontend/src/components/Pages/Event.jsx index d60a3fc..0b5dfe6 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,16 @@ 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 +195,7 @@ function Event() { ))}
-
From cfa44099a011dcb82e3fb4b47eb7ebddcd9fa141 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:25:38 +0000 Subject: [PATCH 4/5] docs(contributor): contrib-readme-action has updated readme --- README.md | 138 ++++++++++-------------------------------------------- 1 file changed, 25 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index c2ec761..28a1537 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
- - - haseebzaki-07 -
- Haseeb Zaki -
- - - - jainaryan04 -
- Aryan Ramesh Jain -
- alo7lika @@ -280,8 +266,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made alolika bhowmik - - Ashwinib26 @@ -296,6 +280,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mahera Nayan + + tejasbenibagde @@ -310,13 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Tyarla Shirisha - - - NilanchalaPanda -
- Nilanchal -
- Amnyadav @@ -324,20 +303,18 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Aman Yadav - - - - VinayLodhi1712 + + NilanchalaPanda
- Vinay Anand Lodhi + Nilanchal
- - meghanakn22 + + haseebzaki-07
- meghanakn22 + Haseeb Zaki
@@ -347,13 +324,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sawan kushwah - - - Sumanbhadra -
- Suman Bhadra -
- + + Suhas-Koheda @@ -368,8 +340,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jay shah - - vishnuprasad2004 @@ -377,13 +347,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishnu Prasad Korada - - - Sourabh782 -
- Sourabh Singh Rawat -
- sajalbatra @@ -405,27 +368,20 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Abhijit Motekar + + Navneetdadhich
Navneet Dadhich
- - - - - - CoderFleet -
- Rudransh Pratap Singh -
- - AE-Hertz + + VinayLodhi1712
- Abhinandan + Vinay Anand Lodhi
@@ -458,13 +414,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - - vaishnavipal1869 -
- vaishnavipal1869 -
- tanishirai @@ -480,28 +429,19 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - Shiva-Bajpai + + Sourabh782
- Shiva Bajpai + Sourabh Singh Rawat
- - Pushpa472 + + Shiva-Bajpai
- Pushpa Vishwakarma + Shiva Bajpai
- - - Mansi07sharma -
- Mansi Sharma -
- - - devxMani @@ -509,13 +449,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made MANI - - - meghanakn473 -
- K N Meghana -
- Ayush215mb @@ -523,6 +456,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ayush Yadav + + smog-root @@ -544,8 +479,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vaibhav-Kumar-K-R - - Syed-Farazuddin @@ -567,13 +500,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sapna Kul - - - Nikhil0-3 -
- Nikhil More -
- + + MutiatBash @@ -588,8 +516,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mohit Rana - - jaidh01 @@ -597,13 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jai Dhingra - - - harjasae2001 -
- Harjas Singh -
- mishradev1 @@ -618,13 +537,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made CHIKATLA RAKESH - - - AnushkaChouhan25 -
- Anushka Chouhan -
- AliGates915 From 3485129f0716d2a1d45044667838e89fad7981f4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:32:12 +0000 Subject: [PATCH 5/5] docs(contributor): contrib-readme-action has updated readme --- README.md | 159 +++++++++++------------------------------------------- 1 file changed, 31 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index f9e3a28..28a1537 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 - - - haseebzaki-07 -
- Haseeb Zaki -
- - - - jainaryan04 -
- Aryan Ramesh Jain -
- alo7lika @@ -280,8 +266,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made alolika bhowmik - - Ashwinib26 @@ -289,13 +273,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ashwini_ab - - - tejasbenibagde -
- Tejas Benibagde -
- itznayan @@ -303,29 +280,22 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mahera Nayan + + - - Shirisha-16 -
- Tyarla Shirisha -
- - - - meghanakn22 + + tejasbenibagde
- meghanakn22 + Tejas Benibagde
- - VinayLodhi1712 + + Shirisha-16
- Vinay Anand Lodhi + Tyarla Shirisha
- - Amnyadav @@ -341,17 +311,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - Suhas-Koheda -
- Suhas Koheda -
- - - - Sumanbhadra + + haseebzaki-07
- Suman Bhadra + Haseeb Zaki
@@ -361,15 +324,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sawan kushwah + + - - CoderFleet + + Suhas-Koheda
- Rudransh Pratap Singh + Suhas Koheda
- - Jay-1409 @@ -384,13 +347,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishnu Prasad Korada - - - Sourabh782 -
- Sourabh Singh Rawat -
- sajalbatra @@ -422,10 +378,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - AE-Hertz + + VinayLodhi1712
- Abhinandan + Vinay Anand Lodhi
@@ -435,13 +391,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishal Lade - - - AnushkaChouhan25 -
- Anushka Chouhan -
- REHAN-18 @@ -456,8 +405,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made t rahul prabhu - - Aditya90456 @@ -465,13 +412,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Aditya Bakshi - - - vaishnavipal1869 -
- vaishnavipal1869 -
- + + tanishirai @@ -487,26 +429,17 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - Shiva-Bajpai -
- Shiva Bajpai -
- - - - Pushpa472 + + Sourabh782
- Pushpa Vishwakarma + Sourabh Singh Rawat
- - - - Mansi07sharma + + Shiva-Bajpai
- Mansi Sharma + Shiva Bajpai
@@ -516,13 +449,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made MANI - - - meghanakn473 -
- K N Meghana -
- Ayush215mb @@ -530,6 +456,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ayush Yadav + + smog-root @@ -544,8 +472,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vaibhav._Y - - Vaibhav-Kumar-K-R @@ -574,13 +500,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sapna Kul - - - Nikhil0-3 -
- Nikhil More -
- + + MutiatBash @@ -588,8 +509,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Bashua Mutiat - - Mohitranag18 @@ -604,20 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Jai Dhingra - - - IkkiOcean -
- Vivek Prakash -
- - - - harjasae2001 -
- Harjas Singh -
- mishradev1 @@ -632,8 +537,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made CHIKATLA RAKESH - - AliGates915