remove token through api
Browse files
server.js
CHANGED
@@ -85,6 +85,11 @@ app.get("/auth/login", async (req, res) => {
|
|
85 |
|
86 |
return res.redirect(302, "/");
|
87 |
});
|
|
|
|
|
|
|
|
|
|
|
88 |
app.get("/api/@me", checkUser, async (req, res) => {
|
89 |
const { hf_token } = req.cookies;
|
90 |
try {
|
|
|
85 |
|
86 |
return res.redirect(302, "/");
|
87 |
});
|
88 |
+
app.get("/auth/logout", (req, res) => {
|
89 |
+
res.clearCookie("hf_token");
|
90 |
+
return res.redirect(302, "/");
|
91 |
+
});
|
92 |
+
|
93 |
app.get("/api/@me", checkUser, async (req, res) => {
|
94 |
const { hf_token } = req.cookies;
|
95 |
try {
|
src/components/deploy-button/deploy-button.tsx
CHANGED
@@ -8,7 +8,6 @@ import SpaceIcon from "@/assets/space.svg";
|
|
8 |
import Loading from "../loading/loading";
|
9 |
import Login from "../login/login";
|
10 |
import { Auth } from "./../../../utils/types";
|
11 |
-
import { useCookie } from "react-use";
|
12 |
|
13 |
const MsgToast = ({ url }: { url: string }) => (
|
14 |
<div className="w-full flex items-center justify-center gap-3">
|
@@ -33,7 +32,6 @@ function DeployButton({
|
|
33 |
error: boolean;
|
34 |
auth?: Auth;
|
35 |
}) {
|
36 |
-
const [, , removeToken] = useCookie("hf_token");
|
37 |
const [open, setOpen] = useState(false);
|
38 |
const [loading, setLoading] = useState(false);
|
39 |
const [path, setPath] = useState<string | undefined>(undefined);
|
@@ -87,8 +85,8 @@ function DeployButton({
|
|
87 |
className="mr-2 cursor-pointer"
|
88 |
onClick={() => {
|
89 |
if (confirm("Are you sure you want to log out?")) {
|
90 |
-
|
91 |
-
window.location.
|
92 |
}
|
93 |
}}
|
94 |
>
|
|
|
8 |
import Loading from "../loading/loading";
|
9 |
import Login from "../login/login";
|
10 |
import { Auth } from "./../../../utils/types";
|
|
|
11 |
|
12 |
const MsgToast = ({ url }: { url: string }) => (
|
13 |
<div className="w-full flex items-center justify-center gap-3">
|
|
|
32 |
error: boolean;
|
33 |
auth?: Auth;
|
34 |
}) {
|
|
|
35 |
const [open, setOpen] = useState(false);
|
36 |
const [loading, setLoading] = useState(false);
|
37 |
const [path, setPath] = useState<string | undefined>(undefined);
|
|
|
85 |
className="mr-2 cursor-pointer"
|
86 |
onClick={() => {
|
87 |
if (confirm("Are you sure you want to log out?")) {
|
88 |
+
// go to /auth/logout page
|
89 |
+
window.location.href = "/auth/logout";
|
90 |
}
|
91 |
}}
|
92 |
>
|