Skip to content

Commit

Permalink
feat: show the user an appropriate error when rate limited
Browse files Browse the repository at this point in the history
  • Loading branch information
PudgyPug committed Nov 26, 2024
1 parent 0564d1d commit 14be436
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ const login = async (apiBase: string, password: string) => {
body: JSON.stringify({ password: sha256digest }),
credentials: 'include',
});
await res.json();
if (!res.ok) {
if (res.status === 403) {
throw new Error('The password you’ve entered is invalid. Please enter the correct password');
} else if (res.status === 429) {
throw new Error('Too many login attempts from this IP, please try again after 20 minutes');
} else {
throw new Error('Something went wrong. Please try again later.');
}
}
await res.json();
localStorage.setItem(isLoggedInKey, 'true');

const isFirstTimeUserFlagPresent = localStorage.getItem(isFirstTimeUserKey);
Expand Down

0 comments on commit 14be436

Please sign in to comment.