-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathUser.tsx
More file actions
86 lines (79 loc) · 2.28 KB
/
User.tsx
File metadata and controls
86 lines (79 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React from "react";
import { SignedIn, SignedOut, SignInButton, UserButton } from "@clerk/clerk-react";
// let user;
// export const clerk = new Clerk(import.meta.env.VITE_CLERK_PUBLISHABLE_KEY);
// await clerk.load({
// signInUrl: "/login",
// appearance: {
// elements: {
// footerAction: { display: "none" },
// },
// },
// });
// user = clerk.user;
// export const authResult = { user };
export function User() {
// const { isLoaded, session, isSignedIn } = useSession();
/*
if (!authResult.user) {
return redirect(`/login?next_url=${encodeURIComponent(window.location.href)}`);
}
*/
// db.connect(getFPCloud({
// ledgerId: "ledgerId",
// // clerkSession: session,
// // tokenFactory: async () => {
// // const token = await session.getToken({
// // template: "with-email",
// // });
// // return token;
// // }
// }))
// useEffect(() => {
// if (isSignedIn && isLoaded) {
// session
// .getToken({
// template: "with-email",
// // leewayInSeconds: 60
// })
// .then((token) => {
// console.log(token);
// // setToken(token!)
// fetch('http://localhost:7370/', {
// method: 'POST',
// body: JSON.stringify({
// type: "tbd",
// auth: {
// type: "clerk",
// token: token
// }
// }),
// }).catch(console.error).then(async (res) => {
// if (res && res.ok) {
// console.log(JSON.parse(await res.text()));
// }
// })
// });
// }
// }, [session, isLoaded, isSignedIn]);
// console.log("User", isLoaded, isSignedIn, session);
// if (isLoaded && !isSignedIn) {
return (
<>
<SignedIn>
{/* Login */}
<UserButton />
</SignedIn>
<SignedOut>
{/* LoggedIn */}
<SignInButton>
<img
src={"https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp"}
alt={"User profile"}
className="w-8 h-8 rounded-full"
/>
</SignInButton>
</SignedOut>
</>
);
}