fix: use axios error instead of generic error in login page

This commit is contained in:
Stavros
2025-05-20 17:16:08 +03:00
parent e8190456c3
commit 97b0d3e350
3 changed files with 8 additions and 7 deletions

View File

@@ -49,5 +49,5 @@
"forgotPasswordTitle": "Forgot your password?",
"failedToFetchProvidersTitle": "Failed to load authentication providers. Please check your configuration.",
"errorTitle": "An error occurred",
"errorSubtitle": "An error occured while trying to perform this action. Please check the console for more information."
"errorSubtitle": "An error occurred while trying to perform this action. Please check the console for more information."
}

View File

@@ -49,5 +49,5 @@
"forgotPasswordTitle": "Forgot your password?",
"failedToFetchProvidersTitle": "Failed to load authentication providers. Please check your configuration.",
"errorTitle": "An error occurred",
"errorSubtitle": "An error occured while trying to perform this action. Please check the console for more information."
"errorSubtitle": "An error occurred while trying to perform this action. Please check the console for more information."
}

View File

@@ -16,7 +16,7 @@ import { useUserContext } from "@/context/user-context";
import { useIsMounted } from "@/lib/hooks/use-is-mounted";
import { LoginSchema } from "@/schemas/login-schema";
import { useMutation } from "@tanstack/react-query";
import axios from "axios";
import axios, { AxiosError } from "axios";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { Navigate, useLocation } from "react-router";
@@ -85,9 +85,10 @@ export const LoginPage = () => {
);
}, 500);
},
onError: (error: Error) => {
onError: (error: AxiosError) => {
toast.error(t("loginFailTitle"), {
description: error.message.includes("429")
description:
error.response?.status === 429
? t("loginFailRateLimit")
: t("loginFailSubtitle"),
});