Spaces:
Runtime error
Runtime error
test hf signin
Browse files- app/api/login/route.ts +10 -0
- components/main/index.tsx +7 -9
app/api/login/route.ts
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export async function GET(request: Request) {
|
2 |
+
console.log(process.env)
|
3 |
+
return Response.json(
|
4 |
+
{
|
5 |
+
redirect: `https://huggingface.co/oauth/authorize?redirect_uri=${process.env.REDIRECT_URI}&scope=openid%20profile&client_id=${process.env.CLIENT_ID}&state=${process.env.STATE}`,
|
6 |
+
status: 200,
|
7 |
+
ok: true
|
8 |
+
}
|
9 |
+
)
|
10 |
+
}
|
components/main/index.tsx
CHANGED
@@ -30,6 +30,12 @@ export const Main = () => {
|
|
30 |
const [category, setCategory] = useState<string>("community");
|
31 |
const [advancedSettings, setAdvancedSettings] = useState<boolean>(false);
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
return (
|
34 |
<main className="px-6 z-[2] relative max-w-[1722px] mx-auto">
|
35 |
<div className="py-2 pl-2 pr-2 lg:pr-4 bg-black bg-opacity-30 backdrop-blur-sm lg:sticky lg:top-4 z-10 rounded-full">
|
@@ -38,15 +44,7 @@ export const Main = () => {
|
|
38 |
<div className="items-center justify-center lg:justify-end gap-5 w-full mt-6 lg:mt-0 hidden lg:flex">
|
39 |
{categories.map(({ key, label, icon, isLogged }) =>
|
40 |
isLogged && !user ? (
|
41 |
-
<Button
|
42 |
-
key={key}
|
43 |
-
theme="white"
|
44 |
-
onClick={() =>
|
45 |
-
console.log(
|
46 |
-
`https://huggingface.co/oauth/authorize?redirect_uri=${process.env.REDIRECT_URI}&scope=openid%20profile&client_id=${process.env.CLIENT_ID}&state=${process.env.STATE}`
|
47 |
-
)
|
48 |
-
}
|
49 |
-
>
|
50 |
Sign in with Hugging Face
|
51 |
</Button>
|
52 |
) : (
|
|
|
30 |
const [category, setCategory] = useState<string>("community");
|
31 |
const [advancedSettings, setAdvancedSettings] = useState<boolean>(false);
|
32 |
|
33 |
+
const openLogin = async () => {
|
34 |
+
const response = await fetch(`/api/login`);
|
35 |
+
const data = await response.json();
|
36 |
+
console.log(data);
|
37 |
+
};
|
38 |
+
|
39 |
return (
|
40 |
<main className="px-6 z-[2] relative max-w-[1722px] mx-auto">
|
41 |
<div className="py-2 pl-2 pr-2 lg:pr-4 bg-black bg-opacity-30 backdrop-blur-sm lg:sticky lg:top-4 z-10 rounded-full">
|
|
|
44 |
<div className="items-center justify-center lg:justify-end gap-5 w-full mt-6 lg:mt-0 hidden lg:flex">
|
45 |
{categories.map(({ key, label, icon, isLogged }) =>
|
46 |
isLogged && !user ? (
|
47 |
+
<Button key={key} theme="white" onClick={openLogin}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
Sign in with Hugging Face
|
49 |
</Button>
|
50 |
) : (
|