mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
feat: add rate limit warning to frontend
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
"loginSubmit": "Login",
|
"loginSubmit": "Login",
|
||||||
"loginFailTitle": "Failed to log in",
|
"loginFailTitle": "Failed to log in",
|
||||||
"loginFailSubtitle": "Please check your username and password",
|
"loginFailSubtitle": "Please check your username and password",
|
||||||
|
"loginFailRateLimit": "You failed to login too many times, please try again later",
|
||||||
"loginSuccessTitle": "Logged in",
|
"loginSuccessTitle": "Logged in",
|
||||||
"loginSuccessSubtitle": "Welcome back!",
|
"loginSuccessSubtitle": "Welcome back!",
|
||||||
"loginOauthFailTitle": "Internal error",
|
"loginOauthFailTitle": "Internal error",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"loginSubmit": "Login",
|
"loginSubmit": "Login",
|
||||||
"loginFailTitle": "Failed to log in",
|
"loginFailTitle": "Failed to log in",
|
||||||
"loginFailSubtitle": "Please check your username and password",
|
"loginFailSubtitle": "Please check your username and password",
|
||||||
|
"loginFailRateLimit": "You failed to login too many times, please try again later",
|
||||||
"loginSuccessTitle": "Logged in",
|
"loginSuccessTitle": "Logged in",
|
||||||
"loginSuccessSubtitle": "Welcome back!",
|
"loginSuccessSubtitle": "Welcome back!",
|
||||||
"loginOauthFailTitle": "Internal error",
|
"loginOauthFailTitle": "Internal error",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Paper, Title, Text, Divider } from "@mantine/core";
|
import { Paper, Title, Text, Divider } from "@mantine/core";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios, { type AxiosError } from "axios";
|
||||||
import { useUserContext } from "../context/user-context";
|
import { useUserContext } from "../context/user-context";
|
||||||
import { Navigate } from "react-router";
|
import { Navigate } from "react-router";
|
||||||
import { Layout } from "../components/layouts/layout";
|
import { Layout } from "../components/layouts/layout";
|
||||||
@@ -33,7 +33,17 @@ export const LoginPage = () => {
|
|||||||
mutationFn: (login: LoginFormValues) => {
|
mutationFn: (login: LoginFormValues) => {
|
||||||
return axios.post("/api/login", login);
|
return axios.post("/api/login", login);
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: (data: AxiosError) => {
|
||||||
|
if (data.response) {
|
||||||
|
if (data.response.status === 429) {
|
||||||
|
notifications.show({
|
||||||
|
title: t("loginFailTitle"),
|
||||||
|
message: t("loginFailRateLimit"),
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: t("loginFailTitle"),
|
title: t("loginFailTitle"),
|
||||||
message: t("loginFailSubtitle"),
|
message: t("loginFailSubtitle"),
|
||||||
|
|||||||
Reference in New Issue
Block a user