Spaces:
Runtime error
Runtime error
disabled login
Browse files- .DS_Store +0 -0
- app/api/auth/route.ts +1 -0
- assets/.DS_Store +0 -0
- assets/globals.css +3 -0
- assets/images/.DS_Store +0 -0
- assets/images/hf-logo.svg +8 -0
- components/login/index.tsx +23 -4
- utils/useUser.ts +2 -3
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app/api/auth/route.ts
CHANGED
@@ -24,6 +24,7 @@ export async function POST(req: Request) {
|
|
24 |
.json()
|
25 |
.catch(() => ({}));
|
26 |
|
|
|
27 |
if (response.error) return Response.json({ status: 401, ok: false, message: response.error_description });
|
28 |
|
29 |
return Response.json(
|
|
|
24 |
.json()
|
25 |
.catch(() => ({}));
|
26 |
|
27 |
+
console.log(response)
|
28 |
if (response.error) return Response.json({ status: 401, ok: false, message: response.error_description });
|
29 |
|
30 |
return Response.json(
|
assets/.DS_Store
CHANGED
Binary files a/assets/.DS_Store and b/assets/.DS_Store differ
|
|
assets/globals.css
CHANGED
@@ -12,6 +12,9 @@ body {
|
|
12 |
.loading-dots span{
|
13 |
@apply inline-block w-2 h-2 bg-white rounded-full
|
14 |
}
|
|
|
|
|
|
|
15 |
.loading-dots span:nth-child(1) {
|
16 |
animation: move 1s infinite;
|
17 |
}
|
|
|
12 |
.loading-dots span{
|
13 |
@apply inline-block w-2 h-2 bg-white rounded-full
|
14 |
}
|
15 |
+
.loading-dots.grey span{
|
16 |
+
@apply inline-block w-2 h-2 bg-gray-400 rounded-full
|
17 |
+
}
|
18 |
.loading-dots span:nth-child(1) {
|
19 |
animation: move 1s infinite;
|
20 |
}
|
assets/images/.DS_Store
CHANGED
Binary files a/assets/images/.DS_Store and b/assets/images/.DS_Store differ
|
|
assets/images/hf-logo.svg
ADDED
|
components/login/index.tsx
CHANGED
@@ -1,16 +1,35 @@
|
|
1 |
"use client";
|
2 |
|
3 |
-
import { useUser } from "@/utils/useUser";
|
4 |
import { useMount } from "react-use";
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
export const Login = ({ code }: { code?: string }) => {
|
7 |
const { getAuthorization } = useUser();
|
8 |
|
9 |
-
useMount(() => getAuthorization(code as string));
|
10 |
|
11 |
return (
|
12 |
-
<div className="
|
13 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
</div>
|
15 |
);
|
16 |
};
|
|
|
1 |
"use client";
|
2 |
|
|
|
3 |
import { useMount } from "react-use";
|
4 |
+
import Image from "next/image";
|
5 |
+
import { FaUserAstronaut } from "react-icons/fa";
|
6 |
+
|
7 |
+
import { useUser } from "@/utils/useUser";
|
8 |
+
import HFLogo from "@/assets/images/hf-logo.svg";
|
9 |
|
10 |
export const Login = ({ code }: { code?: string }) => {
|
11 |
const { getAuthorization } = useUser();
|
12 |
|
13 |
+
// useMount(() => getAuthorization(code as string));
|
14 |
|
15 |
return (
|
16 |
+
<div className="p-6 min-h-screen flex items-center justify-center">
|
17 |
+
<div className="mx-auto bg-white w-full max-w-sm rounded-3xl p-6">
|
18 |
+
<p className="text-center text-gray-400 uppercase font-bold text-sm">
|
19 |
+
Retrieving your information...
|
20 |
+
</p>
|
21 |
+
<div className="flex items-center justify-evenly mt-3">
|
22 |
+
<Image src={HFLogo} alt="HF Logo" width={100} height={100} />
|
23 |
+
<div className="loading-dots grey translate-y-[5px]">
|
24 |
+
<span />
|
25 |
+
<span />
|
26 |
+
<span />
|
27 |
+
</div>
|
28 |
+
<div className="w-[80px] h-[80px] rounded-full ring-4 ring-indigo-200 border-2 border-white bg-indigo-50 p-3">
|
29 |
+
<FaUserAstronaut className="w-full h-full text-indigo-500" />
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
</div>
|
34 |
);
|
35 |
};
|
utils/useUser.ts
CHANGED
@@ -36,8 +36,6 @@ export const useUser = () => {
|
|
36 |
}
|
37 |
);
|
38 |
|
39 |
-
const setCookieToken = async (token: string) => setValue(token, { expires: 7 });
|
40 |
-
|
41 |
useUpdateEffect(() => {
|
42 |
if (value) {
|
43 |
refetch()
|
@@ -54,6 +52,7 @@ export const useUser = () => {
|
|
54 |
};
|
55 |
|
56 |
const getAuthorization = async (code: string) => {
|
|
|
57 |
const request = await fetch("/api/auth", {
|
58 |
method: "POST",
|
59 |
body: JSON.stringify({
|
@@ -65,6 +64,7 @@ export const useUser = () => {
|
|
65 |
setValue(res.access_token, {
|
66 |
expires: res.experes_in,
|
67 |
});
|
|
|
68 |
}
|
69 |
|
70 |
return {
|
@@ -72,7 +72,6 @@ export const useUser = () => {
|
|
72 |
user,
|
73 |
refetch,
|
74 |
loading,
|
75 |
-
setCookieToken,
|
76 |
getAuthorization
|
77 |
}
|
78 |
}
|
|
|
36 |
}
|
37 |
);
|
38 |
|
|
|
|
|
39 |
useUpdateEffect(() => {
|
40 |
if (value) {
|
41 |
refetch()
|
|
|
52 |
};
|
53 |
|
54 |
const getAuthorization = async (code: string) => {
|
55 |
+
console.log(code)
|
56 |
const request = await fetch("/api/auth", {
|
57 |
method: "POST",
|
58 |
body: JSON.stringify({
|
|
|
64 |
setValue(res.access_token, {
|
65 |
expires: res.experes_in,
|
66 |
});
|
67 |
+
window.location.href = "/";
|
68 |
}
|
69 |
|
70 |
return {
|
|
|
72 |
user,
|
73 |
refetch,
|
74 |
loading,
|
|
|
75 |
getAuthorization
|
76 |
}
|
77 |
}
|