Skip to content

Commit

Permalink
Fix user not found and invalid password alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 18, 2024
1 parent 05dcd44 commit 56fc2c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend/src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ export default function SignIn() {

if (response.status === 404) {
setIsLoading(false);
alert("User not found");
} else if (response.status === 401) {
setIsLoading(false);
alert("Invalid password");
} else {
} else if (response.status === 200) {
const data = await response.json();
localStorage.setItem("token", data.token);
const decodedToken: any = jwt.decode(data.token);
localStorage.setItem("userId", decodedToken.userId);
localStorage.setItem("userId", decodedToken.id);
localStorage.setItem("name", username);
router.push("/chat");
} else {
setIsLoading(false);
console.log(response.status);
alert(response);
}
};

Expand Down

0 comments on commit 56fc2c9

Please sign in to comment.