mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(web): unrecoverable unauthorized error (#843)
fix:unauthorized error. added check for failed login as well remove user when visiting login. Co-authored-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
286f2f53f7
commit
0087147660
1 changed files with 13 additions and 0 deletions
|
@ -7,6 +7,8 @@ import { APIClient } from "../../api/APIClient";
|
||||||
import { AuthContext } from "../../utils/Context";
|
import { AuthContext } from "../../utils/Context";
|
||||||
import { PasswordInput, TextInput } from "../../components/inputs/text";
|
import { PasswordInput, TextInput } from "../../components/inputs/text";
|
||||||
import { Tooltip } from "react-tooltip";
|
import { Tooltip } from "react-tooltip";
|
||||||
|
import Toast from "@/components/notifications/Toast";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
type LoginFormFields = {
|
type LoginFormFields = {
|
||||||
username: string;
|
username: string;
|
||||||
|
@ -22,6 +24,12 @@ export const Login = () => {
|
||||||
const [, setAuthContext] = AuthContext.use();
|
const [, setAuthContext] = AuthContext.use();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// remove user session when visiting login page'
|
||||||
|
APIClient.auth.logout()
|
||||||
|
.then(() => {
|
||||||
|
AuthContext.reset();
|
||||||
|
});
|
||||||
|
|
||||||
// Check if onboarding is available for this instance
|
// Check if onboarding is available for this instance
|
||||||
// and redirect if needed
|
// and redirect if needed
|
||||||
APIClient.auth.canOnboard()
|
APIClient.auth.canOnboard()
|
||||||
|
@ -38,6 +46,11 @@ export const Login = () => {
|
||||||
isLoggedIn: true
|
isLoggedIn: true
|
||||||
});
|
});
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
toast.custom((t) => (
|
||||||
|
<Toast type="error" body="Wrong password or username!" t={t} />
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue