Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Profile Page for users to see Reservations #437

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 32 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,73 +259,43 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Arindam</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/haseebzaki-07">
<img src="https://avatars.githubusercontent.com/u/147314463?v=4" width="100;" alt="haseebzaki-07"/>
<br />
<sub><b>Haseeb Zaki</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/jainaryan04">
<img src="https://avatars.githubusercontent.com/u/138214350?v=4" width="100;" alt="jainaryan04"/>
<br />
<sub><b>Aryan Ramesh Jain</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/alo7lika">
<img src="https://avatars.githubusercontent.com/u/152315710?v=4" width="100;" alt="alo7lika"/>
<br />
<sub><b>alolika bhowmik</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Ashwinib26">
<img src="https://avatars.githubusercontent.com/u/149402720?v=4" width="100;" alt="Ashwinib26"/>
<br />
<sub><b>Ashwini_ab</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/tejasbenibagde">
<img src="https://avatars.githubusercontent.com/u/124677750?v=4" width="100;" alt="tejasbenibagde"/>
<br />
<sub><b>Tejas Benibagde</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/itznayan">
<img src="https://avatars.githubusercontent.com/u/136584376?v=4" width="100;" alt="itznayan"/>
<br />
<sub><b>Mahera Nayan</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Shirisha-16">
<img src="https://avatars.githubusercontent.com/u/148051550?v=4" width="100;" alt="Shirisha-16"/>
<br />
<sub><b>Tyarla Shirisha</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/meghanakn22">
<img src="https://avatars.githubusercontent.com/u/172406754?v=4" width="100;" alt="meghanakn22"/>
<a href="https://github.com/tejasbenibagde">
<img src="https://avatars.githubusercontent.com/u/124677750?v=4" width="100;" alt="tejasbenibagde"/>
<br />
<sub><b>meghanakn22</b></sub>
<sub><b>Tejas Benibagde</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/VinayLodhi1712">
<img src="https://avatars.githubusercontent.com/u/135756009?v=4" width="100;" alt="VinayLodhi1712"/>
<a href="https://github.com/Shirisha-16">
<img src="https://avatars.githubusercontent.com/u/148051550?v=4" width="100;" alt="Shirisha-16"/>
<br />
<sub><b>Vinay Anand Lodhi</b></sub>
<sub><b>Tyarla Shirisha</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Amnyadav">
<img src="https://avatars.githubusercontent.com/u/127370497?v=4" width="100;" alt="Amnyadav"/>
Expand All @@ -341,17 +311,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
</a>
</td>
<td align="center">
<a href="https://github.com/Suhas-Koheda">
<img src="https://avatars.githubusercontent.com/u/72063139?v=4" width="100;" alt="Suhas-Koheda"/>
<br />
<sub><b>Suhas Koheda</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Sumanbhadra">
<img src="https://avatars.githubusercontent.com/u/93245252?v=4" width="100;" alt="Sumanbhadra"/>
<a href="https://github.com/haseebzaki-07">
<img src="https://avatars.githubusercontent.com/u/147314463?v=4" width="100;" alt="haseebzaki-07"/>
<br />
<sub><b>Suman Bhadra</b></sub>
<sub><b>Haseeb Zaki</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -361,15 +324,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Sawan kushwah </b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/CoderFleet">
<img src="https://avatars.githubusercontent.com/u/87255169?v=4" width="100;" alt="CoderFleet"/>
<a href="https://github.com/Suhas-Koheda">
<img src="https://avatars.githubusercontent.com/u/72063139?v=4" width="100;" alt="Suhas-Koheda"/>
<br />
<sub><b>Rudransh Pratap Singh</b></sub>
<sub><b>Suhas Koheda</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Jay-1409">
<img src="https://avatars.githubusercontent.com/u/166749819?v=4" width="100;" alt="Jay-1409"/>
Expand All @@ -384,13 +347,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Vishnu Prasad Korada</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Sourabh782">
<img src="https://avatars.githubusercontent.com/u/103349890?v=4" width="100;" alt="Sourabh782"/>
<br />
<sub><b>Sourabh Singh Rawat</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/sajalbatra">
<img src="https://avatars.githubusercontent.com/u/125984550?v=4" width="100;" alt="sajalbatra"/>
Expand Down Expand Up @@ -422,10 +378,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
</a>
</td>
<td align="center">
<a href="https://github.com/AE-Hertz">
<img src="https://avatars.githubusercontent.com/u/93651229?v=4" width="100;" alt="AE-Hertz"/>
<a href="https://github.com/VinayLodhi1712">
<img src="https://avatars.githubusercontent.com/u/135756009?v=4" width="100;" alt="VinayLodhi1712"/>
<br />
<sub><b>Abhinandan</b></sub>
<sub><b>Vinay Anand Lodhi</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -435,13 +391,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Vishal Lade</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/AnushkaChouhan25">
<img src="https://avatars.githubusercontent.com/u/157525924?v=4" width="100;" alt="AnushkaChouhan25"/>
<br />
<sub><b>Anushka Chouhan</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/REHAN-18">
<img src="https://avatars.githubusercontent.com/u/143922855?v=4" width="100;" alt="REHAN-18"/>
Expand All @@ -456,22 +405,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>t rahul prabhu</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Aditya90456">
<img src="https://avatars.githubusercontent.com/u/153073510?v=4" width="100;" alt="Aditya90456"/>
<br />
<sub><b>Aditya Bakshi</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/vaishnavipal1869">
<img src="https://avatars.githubusercontent.com/u/180996531?v=4" width="100;" alt="vaishnavipal1869"/>
<br />
<sub><b>vaishnavipal1869</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/tanishirai">
<img src="https://avatars.githubusercontent.com/u/178164785?v=4" width="100;" alt="tanishirai"/>
Expand All @@ -487,26 +429,17 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
</a>
</td>
<td align="center">
<a href="https://github.com/Shiva-Bajpai">
<img src="https://avatars.githubusercontent.com/u/141490705?v=4" width="100;" alt="Shiva-Bajpai"/>
<br />
<sub><b>Shiva Bajpai</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Pushpa472">
<img src="https://avatars.githubusercontent.com/u/116655535?v=4" width="100;" alt="Pushpa472"/>
<a href="https://github.com/Sourabh782">
<img src="https://avatars.githubusercontent.com/u/103349890?v=4" width="100;" alt="Sourabh782"/>
<br />
<sub><b>Pushpa Vishwakarma </b></sub>
<sub><b>Sourabh Singh Rawat</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Mansi07sharma">
<img src="https://avatars.githubusercontent.com/u/142892607?v=4" width="100;" alt="Mansi07sharma"/>
<a href="https://github.com/Shiva-Bajpai">
<img src="https://avatars.githubusercontent.com/u/141490705?v=4" width="100;" alt="Shiva-Bajpai"/>
<br />
<sub><b>Mansi Sharma</b></sub>
<sub><b>Shiva Bajpai</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -516,20 +449,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>MANI </b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/meghanakn473">
<img src="https://avatars.githubusercontent.com/u/165137755?v=4" width="100;" alt="meghanakn473"/>
<br />
<sub><b>K N Meghana</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Ayush215mb">
<img src="https://avatars.githubusercontent.com/u/154300084?v=4" width="100;" alt="Ayush215mb"/>
<br />
<sub><b>Ayush Yadav</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/smog-root">
<img src="https://avatars.githubusercontent.com/u/181578777?v=4" width="100;" alt="smog-root"/>
Expand All @@ -544,8 +472,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Vaibhav._Y</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Vaibhav-Kumar-K-R">
<img src="https://avatars.githubusercontent.com/u/132189791?v=4" width="100;" alt="Vaibhav-Kumar-K-R"/>
Expand Down Expand Up @@ -574,22 +500,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Sapna Kul</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Nikhil0-3">
<img src="https://avatars.githubusercontent.com/u/149102391?v=4" width="100;" alt="Nikhil0-3"/>
<br />
<sub><b>Nikhil More</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/MutiatBash">
<img src="https://avatars.githubusercontent.com/u/108807732?v=4" width="100;" alt="MutiatBash"/>
<br />
<sub><b>Bashua Mutiat</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Mohitranag18">
<img src="https://avatars.githubusercontent.com/u/152625405?v=4" width="100;" alt="Mohitranag18"/>
Expand All @@ -604,20 +523,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>Jai Dhingra</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/IkkiOcean">
<img src="https://avatars.githubusercontent.com/u/76002919?v=4" width="100;" alt="IkkiOcean"/>
<br />
<sub><b>Vivek Prakash</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/harjasae2001">
<img src="https://avatars.githubusercontent.com/u/83627055?v=4" width="100;" alt="harjasae2001"/>
<br />
<sub><b>Harjas Singh</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/mishradev1">
<img src="https://avatars.githubusercontent.com/u/118660840?v=4" width="100;" alt="mishradev1"/>
Expand All @@ -632,8 +537,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
<sub><b>CHIKATLA RAKESH</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/AliGates915">
<img src="https://avatars.githubusercontent.com/u/128673394?v=4" width="100;" alt="AliGates915"/>
Expand Down Expand Up @@ -697,7 +600,4 @@ Stay updated and engage with our community on social media:
- [LinkedIn](https://www.linkedin.com/in/ramakrushna-biswal/)
- [Email](mailto:[email protected])

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.
3 changes: 2 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ GOOGLE_CLIENT_SECRET=your_google_client_secret
FRONTEND_URL=your_frontend_url
CALLBACK_URL=http://localhost:3000/auth/google/callback
PROD_CALLBACK_URL=https://play-cafe.vercel.app/auth/google/callback
NODE_ENV=development
NODE_ENV=development
SECRET_KEY=your_secret_key
33 changes: 11 additions & 22 deletions backend/controller/customer.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ async function loginCustomer(req, res) {
password: z.string().min(6, "Password must be at least 6 characters long"),
});


const validation = customerLoginSchema.safeParse(req.body);
if (!validation.success) {
return res.status(400).json({ error: validation.error.errors });
}

try {
const customer = await Customer.findOne({ email: req.body.email });

if (!customer) {
return res.status(401).json({ error: "Invalid email or password" });
}
Expand All @@ -106,35 +105,26 @@ async function loginCustomer(req, res) {
}

const validPassword = await bcrypt.compare(req.body.password, customer.password);

if (!validPassword) {
return res.status(401).json({ error: "Invalid email or password" });
}

const payload = {
sub: customer._id,
name: customer.name, // Optional
role: "customer", // Optional
email: customer.email, // Optional
};

const token = jwt.sign(
payload,
process.env.JWT_SECRET,
{ expiresIn: "1h" } // Expires in 1 hour
);

req.session.user = {
id: customer._id,
sub: customer._id, // Use `sub` as this is a standard JWT claim for subject (user ID)
name: customer.name,
role: "customer",
email: customer.email,
Comment on lines +113 to +116
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider reducing sensitive information in JWT payload

While the JWT payload structure is well-organized, consider minimizing sensitive data exposure:

  1. The email field in the payload might not be necessary since you already have the user ID
  2. Add null checks for customer.name before including it in the payload

Apply this diff to improve security:

 const payload = {
   sub: customer._id, // Use `sub` as this is a standard JWT claim for subject (user ID)
-  name: customer.name,
+  name: customer.name || '',
   role: "customer",
-  email: customer.email,
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sub: customer._id, // Use `sub` as this is a standard JWT claim for subject (user ID)
name: customer.name,
role: "customer",
email: customer.email,
sub: customer._id, // Use `sub` as this is a standard JWT claim for subject (user ID)
name: customer.name || '',
role: "customer",

};

const token = jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: "1h" });

res.cookie("authToken", token, {
maxAge: 1000 * 60 * 60,
httpOnly: true,
secure: true,
maxAge: 60 * 60 * 1000, // 1 hour
httpOnly: false, // Set to false if you need access on the frontend
secure: process.env.NODE_ENV === "production", // Set `secure: true` only in production with HTTPS
sameSite: "strict", // Use `strict` to avoid CSRF in most cases
Comment on lines +122 to +125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security risk: Cookie configuration exposes JWT to XSS attacks

The current cookie configuration has security implications:

  1. Setting httpOnly: false exposes the JWT to potential XSS attacks
  2. Frontend access to JWT can be achieved through other secure means

Consider these improvements:

  1. Set httpOnly to true and implement a separate mechanism for frontend authentication:
 res.cookie("authToken", token, {
   maxAge: 60 * 60 * 1000, // 1 hour
-  httpOnly: false, // Set to false if you need access on the frontend
+  httpOnly: true,
   secure: process.env.NODE_ENV === "production",
   sameSite: "strict",
 });
  1. If frontend needs the token, consider sending it separately in the response body while keeping the httpOnly cookie for backend authentication.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
maxAge: 60 * 60 * 1000, // 1 hour
httpOnly: false, // Set to false if you need access on the frontend
secure: process.env.NODE_ENV === "production", // Set `secure: true` only in production with HTTPS
sameSite: "strict", // Use `strict` to avoid CSRF in most cases
maxAge: 60 * 60 * 1000, // 1 hour
httpOnly: true,
secure: process.env.NODE_ENV === "production", // Set `secure: true` only in production with HTTPS
sameSite: "strict", // Use `strict` to avoid CSRF in most cases

});

Comment on lines +119 to +127
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Based on the comprehensive review of the authentication implementation, I can now provide the final response:

Authentication setup is incomplete for profile page requirements

The current authentication implementation has some gaps that need to be addressed:

  • No dedicated profile-related endpoints exist in customerRouter.js for viewing or updating user profiles
  • The JWT authentication is properly implemented with middleware but session-based logout (req.session.destroy) is inconsistent with the JWT approach
  • Frontend access to auth token is enabled (httpOnly: false) but there's no profile data retrieval endpoint to utilize this token
🔗 Analysis chain

Verify authentication flow with profile page requirements

The authentication implementation needs to be verified against the profile page requirements from issue #192.

Let's verify the authentication setup:


Let me gather more information about the authentication implementation and profile-related endpoints.


Let me check the customer routes and controller to understand the complete authentication flow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if profile routes are properly protected
echo "Checking for protected profile routes..."
rg -l "profile.*router" backend/

# Verify consistent auth middleware usage
echo "Checking auth middleware usage..."
rg -A 3 "authenticateCustomer" backend/

Length of output: 2210


Script:

#!/bin/bash
# Check for profile-related endpoints and their authentication
echo "Checking profile endpoints..."
rg -A 5 "profile" backend/

# Check auth middleware implementation
echo "Checking auth middleware implementation..."
cat backend/middlewares/authCustomer.js

# Check customer controller for profile-related functions
echo "Checking customer controller..."
rg -A 5 "profile" backend/controller/customer.controller.js

Length of output: 3188


Script:

#!/bin/bash
# Check customer routes
echo "Checking customer routes..."
cat backend/routes/customerRouter.js

# Check customer controller
echo "Checking customer controller..."
cat backend/controller/customer.controller.js

Length of output: 6848

return res.json({
message: "Login successful",
token,
Expand All @@ -147,7 +137,6 @@ async function loginCustomer(req, res) {
});
} catch (error) {
console.error("Error during login:", error);

res.status(500).json({ error: "Internal server error" });
}
}
Expand Down
Loading
Loading