Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARD-983: show the user an appropriate error when rate limited #66

Merged
merged 1 commit into from
Nov 29, 2024
Merged
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
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