Spaces:
Runtime error
Runtime error
check the error in prod
Browse files- components/login/index.tsx +1 -4
- utils/useUser.ts +2 -7
components/login/index.tsx
CHANGED
@@ -10,7 +10,7 @@ import classNames from "classnames";
|
|
10 |
import { HiCheckBadge } from "react-icons/hi2";
|
11 |
|
12 |
export const Login = ({ code }: { code?: string }) => {
|
13 |
-
const { getAuthorization, user
|
14 |
|
15 |
useMount(() => getAuthorization(code as string));
|
16 |
|
@@ -52,9 +52,6 @@ export const Login = ({ code }: { code?: string }) => {
|
|
52 |
<FaUserAstronaut className="w-full h-full text-indigo-500" />
|
53 |
</div>
|
54 |
</div>
|
55 |
-
{error && (
|
56 |
-
<p className="text-black text-sm">{JSON.stringify(error, null, 2)}</p>
|
57 |
-
)}
|
58 |
</div>
|
59 |
</div>
|
60 |
);
|
|
|
10 |
import { HiCheckBadge } from "react-icons/hi2";
|
11 |
|
12 |
export const Login = ({ code }: { code?: string }) => {
|
13 |
+
const { getAuthorization, user } = useUser();
|
14 |
|
15 |
useMount(() => getAuthorization(code as string));
|
16 |
|
|
|
52 |
<FaUserAstronaut className="w-full h-full text-indigo-500" />
|
53 |
</div>
|
54 |
</div>
|
|
|
|
|
|
|
55 |
</div>
|
56 |
</div>
|
57 |
);
|
utils/useUser.ts
CHANGED
@@ -6,7 +6,6 @@ import { useState } from "react";
|
|
6 |
|
7 |
export const useUser = () => {
|
8 |
const [value, setValue, remove] = useCookie("auth_hf_token");
|
9 |
-
const [error, setError] = useState(null);
|
10 |
|
11 |
const {
|
12 |
data: user,
|
@@ -65,16 +64,13 @@ export const useUser = () => {
|
|
65 |
});
|
66 |
const res = await request.clone().json().catch(() => ({}));
|
67 |
if (!res.ok) {
|
68 |
-
setError(res);
|
69 |
return null;
|
70 |
}
|
71 |
setValue(res.access_token, {
|
72 |
-
expires:
|
73 |
-
|
74 |
-
),
|
75 |
path: "/",
|
76 |
secure: true,
|
77 |
-
httpOnly: true,
|
78 |
});
|
79 |
}
|
80 |
|
@@ -84,7 +80,6 @@ export const useUser = () => {
|
|
84 |
refetch,
|
85 |
loading,
|
86 |
token: `Bearer ${value}`,
|
87 |
-
error,
|
88 |
getAuthorization
|
89 |
}
|
90 |
}
|
|
|
6 |
|
7 |
export const useUser = () => {
|
8 |
const [value, setValue, remove] = useCookie("auth_hf_token");
|
|
|
9 |
|
10 |
const {
|
11 |
data: user,
|
|
|
64 |
});
|
65 |
const res = await request.clone().json().catch(() => ({}));
|
66 |
if (!res.ok) {
|
|
|
67 |
return null;
|
68 |
}
|
69 |
setValue(res.access_token, {
|
70 |
+
expires: res.experes_in,
|
71 |
+
sameSite: "none",
|
|
|
72 |
path: "/",
|
73 |
secure: true,
|
|
|
74 |
});
|
75 |
}
|
76 |
|
|
|
80 |
refetch,
|
81 |
loading,
|
82 |
token: `Bearer ${value}`,
|
|
|
83 |
getAuthorization
|
84 |
}
|
85 |
}
|