logout/login from anywhere

This commit is contained in:
Oliver Bryan
2025-12-22 06:36:14 +00:00
parent e550b936e0
commit bba672a020
3 changed files with 4 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { Button } from "@/components/ui/button";
import LogOutButton from "./components/log-out-button";
function Test() {
return (
@@ -9,6 +10,7 @@ function Test() {
<div className="flex gap-4">
<Button linkTo="/">go back to "/"</Button>
</div>
<LogOutButton />
</main>
);
}

View File

@@ -5,7 +5,7 @@ export default function LogOutButton() {
const logOut = () => {
localStorage.removeItem("token");
localStorage.removeItem("user");
window.location.href = "/";
window.location.href = "";
};
return (

View File

@@ -69,7 +69,7 @@ export default function LogInForm() {
const data = await res.json();
localStorage.setItem("token", data.token);
localStorage.setItem("user", data.user);
window.location.href = "/";
window.location.href = "";
}
// unauthorized
else if (res.status === 401) {