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 { PasswordInput, TextInput } from "../../components/inputs/text";
|
||||
import { Tooltip } from "react-tooltip";
|
||||
import Toast from "@/components/notifications/Toast";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
type LoginFormFields = {
|
||||
username: string;
|
||||
|
@ -22,6 +24,12 @@ export const Login = () => {
|
|||
const [, setAuthContext] = AuthContext.use();
|
||||
|
||||
useEffect(() => {
|
||||
// remove user session when visiting login page'
|
||||
APIClient.auth.logout()
|
||||
.then(() => {
|
||||
AuthContext.reset();
|
||||
});
|
||||
|
||||
// Check if onboarding is available for this instance
|
||||
// and redirect if needed
|
||||
APIClient.auth.canOnboard()
|
||||
|
@ -38,6 +46,11 @@ export const Login = () => {
|
|||
isLoggedIn: true
|
||||
});
|
||||
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