Skip to content

Commit e2f8f7d

Browse files
YuvalYuval
authored andcommitted
fix(LoginScreen): surface Hebrew error for bad credentials and network failures
Map login failure by HTTP status: - 401 -> "סיסמא או שם משתמש לא נכונים" - 0/undefined (network) -> "לא ניתן להתחבר לשרת, נסו שוב מאוחר יותר" - 5xx -> "שגיאת שרת, נסו שוב בעוד מספר רגעים" - other -> fall back to the error message, or a generic login error Replaces the catch-all that leaked raw backend messages (or bare "שגיאה בהתחברות") for wrong-password attempts.
1 parent 7a5f84a commit e2f8f7d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

03-Client/src/app/components/LoginScreen.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ export function LoginScreen() {
4141
try {
4242
await login(email, password);
4343
// GuestRoute handles redirect: /questions for new users, /main for returning users
44-
} catch (err: any) {
45-
setError(err.message || "שגיאה בהתחברות");
44+
} catch (err: unknown) {
45+
const status = (err as { status?: number })?.status;
46+
if (status === 401) {
47+
setError("סיסמא או שם משתמש לא נכונים");
48+
} else if (status === 0 || status === undefined) {
49+
setError("לא ניתן להתחבר לשרת, נסו שוב מאוחר יותר");
50+
} else if (status >= 500) {
51+
setError("שגיאת שרת, נסו שוב בעוד מספר רגעים");
52+
} else {
53+
const message = err instanceof Error ? err.message : "";
54+
setError(message || "שגיאה בהתחברות");
55+
}
4656
} finally {
4757
setLoading(false);
4858
}

0 commit comments

Comments
 (0)