diff --git a/AppImage/components/login.tsx b/AppImage/components/login.tsx index 6bc745ba..3278ca57 100644 --- a/AppImage/components/login.tsx +++ b/AppImage/components/login.tsx @@ -82,14 +82,20 @@ export function Login({ onLogin }: LoginProps) { const data = await response.json() - if (data.requires_totp) { + if (response.ok && data.requires_totp) { setRequiresTotp(true) setLoading(false) return } if (!response.ok) { - throw new Error(data.message || t("login.loginFailed")) + if (response.status === 429) { + throw new Error(t("login.tooManyAttempts")) + } + if (response.status === 401) { + throw new Error(data.requires_totp ? t("login.invalidTotp") : t("login.invalidCredentials")) + } + throw new Error(t("login.loginFailed")) } localStorage.setItem("proxmenux-auth-token", data.token) diff --git a/AppImage/messages/en/common.json b/AppImage/messages/en/common.json index 59fe5c63..8392a658 100644 --- a/AppImage/messages/en/common.json +++ b/AppImage/messages/en/common.json @@ -1402,6 +1402,9 @@ "rememberMe": "Remember me", "missingCredentials": "Please enter username and password", "missingTotp": "Please enter your 2FA code", + "invalidCredentials": "Incorrect username or password", + "invalidTotp": "Incorrect 2FA code", + "tooManyAttempts": "Too many login attempts. Please wait a moment and try again.", "loginFailed": "Login failed", "signingIn": "Signing in...", "signIn": "Sign In", diff --git a/AppImage/messages/sk/common.json b/AppImage/messages/sk/common.json index 9d46bf5a..f2e98787 100644 --- a/AppImage/messages/sk/common.json +++ b/AppImage/messages/sk/common.json @@ -1402,6 +1402,9 @@ "rememberMe": "Zapamätať si ma", "missingCredentials": "Zadajte používateľské meno aj heslo", "missingTotp": "Zadajte 2FA kód", + "invalidCredentials": "Nesprávne používateľské meno alebo heslo", + "invalidTotp": "Nesprávny 2FA kód", + "tooManyAttempts": "Príliš veľa pokusov o prihlásenie. Chvíľu počkajte a skúste to znova.", "loginFailed": "Prihlásenie zlyhalo", "signingIn": "Prihlasujem...", "signIn": "Prihlásiť sa",