mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
logout/login from anywhere
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export default function LogOutButton() {
|
||||
const logOut = () => {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
window.location.href = "/";
|
||||
window.location.href = "";
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user