Conversation
|
@Bhoomi-18 is attempting to deploy a commit to the coderuzumaki's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive profile page with user profile management capabilities and account deletion functionality. The implementation includes both frontend UI components and backend API endpoints to support profile operations.
Key changes:
- Added profile page with editable user information and account deletion
- Implemented backend API routes for profile updates, user retrieval, and account deletion
- Enhanced authentication context with user data management and refresh functionality
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| server/routes/authRoutes.js | Added three new API endpoints: update profile, delete account, and get user profile |
| server/index.js | Updated CORS configuration to support both production and local development origins |
| server/config/db.js | Simplified MongoDB connection by removing deprecated options |
| client/src/routes.jsx | Added new profile page route with protected access |
| client/src/pages/ProfilePage.jsx | Created comprehensive profile page component with edit functionality and account deletion |
| client/src/context/AuthContext.jsx | Enhanced auth context with user token management and refresh capabilities |
| client/src/components/Header.jsx | Updated header component to include profile navigation and improved logout handling |
Files not reviewed (1)
- client/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
client/src/components/Header.jsx:149
- The profile dropdown menu includes a profile link, but there's no visible 'Profile' option being rendered in this diff. Ensure the profile navigation is properly implemented in the dropdown menu.
{isMobileMenuOpen && (
| try { | ||
| const user = await User.findOneAndDelete({ firebase_user_id: uid }); | ||
| if (!user) return res.status(404).json({ error: "User not found" }); | ||
| await admin.auth().deleteUser(uid); // Delete Firebase user |
There was a problem hiding this comment.
The Firebase user deletion should happen before the database deletion to prevent orphaned Firebase users if the database operation fails. Consider reversing the order or implementing proper transaction handling.
| await admin.auth().deleteUser(uid); // Delete Firebase user | |
| // Delete Firebase user first | |
| await admin.auth().deleteUser(uid); | |
| // Then delete from local database | |
| const user = await User.findOneAndDelete({ firebase_user_id: uid }); | |
| if (!user) return res.status(404).json({ error: "User not found" }); |
| { id: 2, action: "Commented on State Management article", date: "Jul 30, 2025" }, | ||
| { id: 3, action: "Joined Practice Room", date: "Jul 28, 2025" }, | ||
| ]; | ||
|
|
There was a problem hiding this comment.
The recent activity data is hardcoded. Consider fetching this data from an API endpoint or making it configurable to display actual user activity.
| const [recentActivity, setRecentActivity] = useState([]); | |
| const [activityLoading, setActivityLoading] = useState(true); | |
| const [activityError, setActivityError] = useState(""); | |
| useEffect(() => { | |
| const fetchRecentActivity = async () => { | |
| setActivityLoading(true); | |
| setActivityError(""); | |
| try { | |
| const res = await axios.get( | |
| `${import.meta.env.VITE_API_URL}/api/user/activity`, | |
| { | |
| headers: { Authorization: `Bearer ${user.token}` }, | |
| withCredentials: true, | |
| } | |
| ); | |
| setRecentActivity(res.data.activities || []); | |
| } catch (err) { | |
| setActivityError("Failed to load recent activity."); | |
| } finally { | |
| setActivityLoading(false); | |
| } | |
| }; | |
| if (user && user.token) { | |
| fetchRecentActivity(); | |
| } | |
| }, [user]); |
| theme: "Light Mode", | ||
| notifications: true, | ||
| language: "English", | ||
| }; |
There was a problem hiding this comment.
The preferences object is hardcoded. Consider fetching user preferences from the backend or implementing a preferences management system.
| }; | |
| // Fetch user preferences from backend | |
| import { useEffect } from "react"; | |
| useEffect(() => { | |
| const fetchPreferences = async () => { | |
| setPreferencesLoading(true); | |
| setPreferencesError(""); | |
| try { | |
| const res = await axios.get( | |
| `${import.meta.env.VITE_API_URL}/api/user/preferences`, | |
| { | |
| headers: { Authorization: `Bearer ${user.token}` }, | |
| withCredentials: true, | |
| } | |
| ); | |
| setPreferences(res.data); | |
| } catch (err) { | |
| setPreferencesError("Failed to load preferences."); | |
| setPreferences(null); | |
| } finally { | |
| setPreferencesLoading(false); | |
| } | |
| }; | |
| if (user && user.token) { | |
| fetchPreferences(); | |
| } | |
| }, [user]); |
| }); | ||
|
|
||
| setMessage("Account deleted. Redirecting..."); | ||
| setTimeout(() => navigate("/login"), 1500); |
There was a problem hiding this comment.
After account deletion, the user should be logged out through the auth context rather than just navigating to login. This ensures proper cleanup of auth state.
| setTimeout(() => navigate("/login"), 1500); | |
| setTimeout(() => logout(), 1500); |
|
|
||
| const confirmLogout = async () => { | ||
| // If you have a delete endpoint, replace this with axios call | ||
| // await axios.delete("/api/user/delete", { headers: { Authorization: `Bearer ${user.token}` } }); |
There was a problem hiding this comment.
The confirmLogout function contains commented code that suggests account deletion logic, but this function should only handle logout. The account deletion logic is misplaced and could cause confusion.
| // await axios.delete("/api/user/delete", { headers: { Authorization: `Bearer ${user.token}` } }); |
|
@CoderUzumaki please review the pr |
|
Hey @Bhoomi-18 , Currently this PR can not be merged as it requires some changes mentioned below:
Please make the necessary changes for this PR to be merged. If you face any issues feel free to contact me. Thank you for your contribution, I am looking forward for your updated PR. |
Description
This PR has added a profile page to the project with the option to delete the account.
Fixes #12
Type of Change
Changes Made
Screenshots (if applicable)
Screen.Recording.2025-08-05.165513.mp4
Environment Variables
.env.exampleNo new environment variables needed.
Checklist
Contributor: @Bhoomi-18