enzostvs HF staff commited on
Commit
f05d143
1 Parent(s): be213e2

check the error in prod

Browse files
Files changed (2) hide show
  1. components/login/index.tsx +1 -4
  2. 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, error } = useUser();
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: new Date(
73
- res.experes_in * 1000 + new Date().getTime()
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
  }