Back

Getting "Server error" on createSession for users

  • 0
  • Self Hosted
  • Web
prokawsar
6 Jun, 2024, 07:24

Following https://appwrite.io/docs/references/cloud/server-nodejs/users#createSession Here is my code sample: try { const response = await users.create(ID.unique(), email, phone); const session = await users.createSession(response.$id); return Response.json({ success: true, message: "User created successfully!", user: response, session: session }); } catch (AppWriteError: unknown) { const error = AppWriteError as AppwriteException;

TypeScript
    return Response.json({
        success: false,
        message: error.message,
        user: null
    });
}

How to create a session for the newly created user? I know creating account will make a session, but I need to create users with email and phone.

Thanks

TL;DR
Developers are encountering a "Server error" when attempting to create a session for new users with email and phone using the Appwrite framework. The issue lies in attempting to create a session immediately after creating a user. To resolve this, developers should call the createSession method with the user's $id, obtained after creating the user.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more