Skip to content

Commit cf60c24

Browse files
committed
refactor(basic-example): Use getPayloadSession instead of getPayloadUser
1 parent 67df23d commit cf60c24

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

examples/basic/src/app/(app)/_components/SignOutButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ export function SignOutButton({
1616
headers: {
1717
"Content-Type": "application/json",
1818
},
19-
}).then(() => {
20-
window.location.reload();
2119
});
20+
window.location.reload();
2221
}}
2322
>
2423
Sign Out

examples/basic/src/app/(app)/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { auth } from "@/auth";
2-
import { getPayloadUser } from "payload-authjs";
2+
import { getPayloadSession } from "payload-authjs";
33
import { SignInButton } from "./_components/SignInButton";
44
import { SignOutButton } from "./_components/SignOutButton";
55

66
const Page = async () => {
7-
const session = await auth();
8-
const payloadUser = await getPayloadUser();
7+
const authjsSession = await auth();
8+
const payloadSession = await getPayloadSession();
99

1010
return (
1111
<main>
12-
{payloadUser ? <SignOutButton /> : <SignInButton />}
12+
{payloadSession ? <SignOutButton /> : <SignInButton />}
1313
<br />
1414
<h3>Auth.js Session</h3>
15-
<pre>{JSON.stringify(session?.user, null, 2)}</pre>
15+
<pre>{JSON.stringify(authjsSession, null, 2)}</pre>
1616
<br />
17-
<h3>Payload CMS User</h3>
18-
<pre>{JSON.stringify(payloadUser, null, 2)}</pre>
17+
<h3>Payload CMS Session</h3>
18+
<pre>{JSON.stringify(payloadSession, null, 2)}</pre>
1919
</main>
2020
);
2121
};

0 commit comments

Comments
 (0)