Skip to content

Commit

Permalink
Fix error handling in SignIn component
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 18, 2024
1 parent 842eb09 commit 05dcd44
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions frontend/src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,16 @@ export default function SignIn() {

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

Expand Down

0 comments on commit 05dcd44

Please sign in to comment.