forked from Github/frigate
return 401 for login failures (#15432)
* return 401 for login failures * only setup the rate limiter when configured
This commit is contained in:
@@ -29,8 +29,11 @@ export function ApiProvider({ children, options }: ApiProviderType) {
|
||||
error.response &&
|
||||
[401, 302, 307].includes(error.response.status)
|
||||
) {
|
||||
window.location.href =
|
||||
error.response.headers.get("location") ?? "login";
|
||||
// redirect to the login page if not already there
|
||||
const loginPage = error.response.headers.get("location") ?? "login";
|
||||
if (window.location.href !== loginPage) {
|
||||
window.location.href = loginPage;
|
||||
}
|
||||
}
|
||||
},
|
||||
...options,
|
||||
|
||||
@@ -63,7 +63,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
||||
toast.error("Exceeded rate limit. Try again later.", {
|
||||
position: "top-center",
|
||||
});
|
||||
} else if (err.response?.status === 400) {
|
||||
} else if (err.response?.status === 401) {
|
||||
toast.error("Login failed", {
|
||||
position: "top-center",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user