Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function createSessionClient() {
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT);

const session = await cookies().get("my-custom-session");
const session = (await cookies()).get("my-custom-session");
if (!session || !session.value) {
throw new Error("No session");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function signUpWithEmail(formData) {
password
});

cookies().set("my-custom-session", session.secret, {
(await cookies()).set("my-custom-session", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
Expand All @@ -93,4 +93,4 @@ async function signUpWithEmail(formData) {
// the SignUpPage component ...
```

The `signUpWithEmail` function is an async function that takes the form data as an argument. It uses the `createAdminClient` function to create an admin Appwrite client and then calls the `createEmailPasswordSession` method on the `account` object. This method takes the email and password as arguments and returns a session object. We then set the session secret in a cookie and redirect the user to the account page.
The `signUpWithEmail` function is an async function that takes the form data as an argument. It uses the `createAdminClient` function to create an admin Appwrite client and then calls the `createEmailPasswordSession` method on the `account` object. This method takes the email and password as arguments and returns a session object. We then await the `cookies()` function (required in Next.js 15) to set the session secret in a secure cookie and redirect the user to the account page.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ async function signOut() {

const { account } = await createSessionClient();

cookies().delete("my-custom-session");
const cookieStore = await cookies();

cookieStore.delete("my-custom-session");
await account.deleteSession({ sessionId: "current" });

redirect("/signup");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { OAuthProvider } from "node-appwrite";
export async function signUpWithGithub() {
const { account } = await createAdminClient();

const origin = headers().get("origin");
const origin = (await headers()).get("origin");

const redirectUrl = await account.createOAuth2Token({
provider: OAuthProvider.Github,
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function GET(request) {
secret
});

cookies().set("my-custom-session", session.secret, {
(await cookies()).set("my-custom-session", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
Expand All @@ -97,4 +97,4 @@ export async function GET(request) {

return NextResponse.redirect(`${request.nextUrl.origin}/account`);
}
```
```