mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 17:29:12 +00:00
fix(web): correctly replace logout url (#316)
* chore(ErrorPage): clean up code, fix typo fix(Logout): replace /logout URL after logging out to / * chore: remove needless TS type export
This commit is contained in:
parent
a84a7364e2
commit
bb2641f447
3 changed files with 14 additions and 13 deletions
|
@ -8,7 +8,7 @@ import { APIClient } from "../../api/APIClient";
|
|||
import { AuthContext } from "../../utils/Context";
|
||||
import { PasswordInput, TextInput } from "../../components/inputs/text";
|
||||
|
||||
export type LoginFormFields = {
|
||||
type LoginFormFields = {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
import { useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { APIClient } from "../../api/APIClient";
|
||||
import Toast from "../../components/notifications/Toast";
|
||||
import { AuthContext } from "../../utils/Context";
|
||||
import Toast from "../../components/notifications/Toast";
|
||||
|
||||
export const Logout = () => {
|
||||
const navigate = useNavigate();
|
||||
useEffect(
|
||||
() => {
|
||||
APIClient.auth.logout()
|
||||
.then(() => {
|
||||
AuthContext.reset();
|
||||
toast.custom((t) => (
|
||||
<Toast type="success" body="You have been logged out. Goodbye!" t={t} />
|
||||
));
|
||||
AuthContext.reset();
|
||||
|
||||
// Dirty way to fix URL without triggering a re-render.
|
||||
// Ideally, we'd move the logout component to a function.
|
||||
setInterval(() => navigate("/", { replace: true }), 250);
|
||||
});
|
||||
},
|
||||
[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue