
Follwoing the docs https://appwrite.io/docs/references/cloud/server-nodejs/account (email sessions) here & got:
⨯ Error: Login failed: account.createEmailSession is not a function

Which version of Appwrite and the node-appwrite
SDK are you using?

"node-appwrite": "^13.0.0",

Are you using Cloud or self-hosting?

self-hosting

Which version are you running?

Version 1.5.7

In the newer versions of the SDK, createEmailSession()
was changed to now be createEmailPasswordSession()
. It still works the same way, just renamed to be clearer

👍 👍

I suggest to update the docs 🙂

The docs on the page you sent were already updated to show the changes https://appwrite.io/docs/references/1.5.x/server-nodejs/account#createEmailPasswordSession

Okay thanks for the quick support! Followup question: after login-in and try to sign out i got: `Logout failed: User (role: guests) missing scope (account)
`

using this code on lib/appwrite: ``` export async function loginUser(email: string, password: string) {
try {
const session = await account.createEmailPasswordSession(email, password);
// Log the session to verify
console.log("Session created:", session);
// Ensure session.$id is valid
if (!session.$id || session.$id.length > 36 || !/^[a-zA-Z0-9._-]+$/.test(session.$id)) {
throw new Error("Invalid session ID");
}
// Store session in cookies
cookies().set("my-custom-session", session.$id, {
httpOnly: true, // Cookie is accessible only by the web server
secure: true, // Cookie will be sent only over HTTPS
sameSite: "strict", // Cookie will be sent only in first-party contexts
});
return session;
} catch (error) {
console.error("Login failed:", error);
throw new Error("Login failed: " + error.message);
}
}
export const logoutUser = async () => { await account.deleteSession('current'); };
export const getSession = async () => { return await account.getSession('current'); }; ```

It looks like you're setting the wrong value for the cookie, you want to be storing the value from session.secret
to the cookie instead. The reason it's failing it because it doesn't register as being logged in with the value being incorrect

Like this: cookies().set(session.secret, session.$id, {
httpOnly: true, // Cookie is accessible only by the web server
secure: true, // Cookie will be sent only over HTTPS
sameSite: "strict", // Cookie will be sent only in first-party contexts
});
?

Like this:
cookies().set("my-custom-session", session.secret, {
httpOnly: true,
secure: true,
sameSite: "strict",
});

Actually when I log-in it returned successfully - I try now with your suggestion thanks - got some rate limit😁 - how long it takes the rate limit?

Can I reset the rate limit when debugging?

There is an environment variable you can change to disable rate limits for self-hosted, set the value of _APP_OPTIONS_ABUSE
to disabled
in your .env
file and then restart the docker containers
Recommended threads
- Need help setting up this error is showi...
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. If you're the app developer, register the redirect URI in the Google Cl...
- Appwrite stopped working, I can't authen...
I'm having an issue with Appwrite. It was working fine just a while ago, but suddenly it stopped working for me and can't authenticate accounts. I even went bac...
- Set succes/failure url in console
Hi guys, I want to set up a succes and failure url for my OAuth2 provider Google. But I don't see any options for this? Is it not possible to do so? Beside th...
