Skip to content
Open
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
9 changes: 6 additions & 3 deletions orbit-app/src/pages/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export const deleteUser = async (userId) => {
return response.data;
};

export const fetchUserProfile = async (userId) => {
const response = await axios.get(`${BASE_URL}/get-user/${userId}`);
async (userId) => {
if (!/^[a-zA-Z0-9_-]+$/.test(userId)) { // Validate userId against a whitelist of allowed characters
throw new Error('Invalid userId');
}
const response = await axios.get(`${BASE_URL}/get-user/${encodeURIComponent(userId)}`); // Encode userId to prevent injection
return response.data;
};
}

function Profile() {
const [userData, setUserData] = useState({});
Expand Down