Skip to content

Commit

Permalink
remove uuid in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina1o1 committed Dec 7, 2023
1 parent 043722d commit 0b2cc75
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
4 changes: 2 additions & 2 deletions back-end/src/routes/loginRouter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const loginRouter = async (req, res) => {
return res.status(200).json({ message: "Successfully logged in!",
accessToken,
user: {
uuid: user.uuid,
name: user.name,
email: user.email
} })
}
})

} catch (error) {
return res.status(500).json({ message: "Internal server error." });
Expand Down
15 changes: 2 additions & 13 deletions front-end/src/pages/Account/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const AccountEdit = (props) => {
const storedUserData = JSON.parse(localStorage.getItem('user') || '{}');
const [username, setUsername] = useState(storedUserData.name || 'John Doe');
const [email, setEmail] = useState(storedUserData.email || '[email protected]');
// console.log(storedUserData.email)

// Set username and email on the screen
useEffect(() => {
Expand Down Expand Up @@ -63,12 +62,7 @@ const AccountEdit = (props) => {

if(response?.data?.user){
setUsername(response.data.user.name);
const userData = {
uuid: response.data.user.uuid,
name: response.data.user.name,
email: response.data.user.email
};
localStorage.setItem('user', JSON.stringify(userData))
localStorage.setItem('user', JSON.stringify(response.data.user))
// localStorage.setItem('username', response.data.user.name);

}else{
Expand Down Expand Up @@ -100,12 +94,7 @@ const AccountEdit = (props) => {

if(response?.data?.user){
setEmail(response.data.user.email);
const userData = {
uuid: response.data.user.uuid,
name: response.data.user.name,
email: response.data.user.email
};
localStorage.setItem('user', JSON.stringify(userData))
localStorage.setItem('user', JSON.stringify(response.data.user))
}else{
console.log("Error!!!!!");
}
Expand Down
7 changes: 1 addition & 6 deletions front-end/src/pages/Authenticate/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ const Login = () => {

// Stores the token and user data in localStorage upon successful login
localStorage.setItem('token', response.data.accessToken);
const userData = {
uuid: response.data.user.uuid,
name: response.data.user.name,
email: response.data.user.email
};
localStorage.setItem('user', JSON.stringify(userData));
localStorage.setItem('user', JSON.stringify(response.data.user));

setLoginMessage("Login successful!"); // Sets a success message
navigate("/"); // Navigates to the home page or dashboard
Expand Down

0 comments on commit 0b2cc75

Please sign in to comment.