Skip to content
Back

[SOLVED] Can't login when I create an account.

  • 0
  • Functions
ideclon
7 Mar, 2024, 11:36

How are you creating account?

TL;DR
Developer encountered login issues after creating an account. The problem was due to using `account.createEmailPasswordSession()`, intended for v1.5, while they should use `account.createEmailSession()` for v1.4. The correct code snippet would be: ```js async function login(email, password) { try { await account.createEmailSession(email, password); // Corrected method const user = await account.get(); setLoggedInUser(user); setSuccessMessage('Logged in successfully.'); setError(''); } catch (error) { console.error('Login failed:', error); setError('Failed
❥Sulfur
7 Mar, 2024, 11:39

Following code:

TypeScript
  async function register(email, password, name) {
    try {
      await account.create(ID.unique(), email, password, name);
      //await login(email, password);
      setSuccessMessage('Registered and logged in successfully.');
    } catch (error) {
      setError('Failed to register. Please try again.');
    }
  }
ideclon
7 Mar, 2024, 11:40

But where are you creating account?

❥Sulfur
7 Mar, 2024, 11:41

await account.create(ID.unique(), email, password, name); but I am assuming you meant: const account = new Account(client);

❥Sulfur
7 Mar, 2024, 11:42

which is missing yes...

Guille
7 Mar, 2024, 11:42

createEmailPasswordSession is for v1.5.0, and this version isn't released yet

❥Sulfur
7 Mar, 2024, 11:42

So what would be the fix hah

ideclon
7 Mar, 2024, 11:43

Only in server side...

ideclon
7 Mar, 2024, 11:43

Yes, I mean const account = new Account(client);

ideclon
7 Mar, 2024, 11:44

Where's that?

Guille
7 Mar, 2024, 11:44

In v1.4 you should use createEmailSession

Guille
7 Mar, 2024, 11:45

createEmailPasswordSession is renamed in v1.5, v1.4 uses createEmailSession

❥Sulfur
7 Mar, 2024, 11:45

I did miss that one yes addind it did produce many of errors tho so assuming I messed up something else.

ideclon
7 Mar, 2024, 11:45

Oh actually, you're right! Docs are so confusing!

ideclon
7 Mar, 2024, 11:46

Yes, as @Guille said, It should be account.createEmailSession(), not account.createEmailPasswordSession()

Guille
7 Mar, 2024, 11:47

Yeah, I've seen many people confused about new methods and functions from 1.5 vs 1.4

❥Sulfur
7 Mar, 2024, 11:47

yep that worked

❥Sulfur
7 Mar, 2024, 11:48

thank you for help both also what docs should I use since I am completly confused now?

ideclon
7 Mar, 2024, 11:48

I usually check the API references and manually select v1.4, but I just glanced at https://appwrite.io/docs/products/auth/email-password this time

ideclon
7 Mar, 2024, 11:48

The docs have been updated to be accurate for v1.5, which hasn't been released yet

Guille
7 Mar, 2024, 11:48

Yean will be better to manually select v1.4 to avoid problems

❥Sulfur
7 Mar, 2024, 11:49

okey so need to look at 1.4 okey yea tnx

Guille
7 Mar, 2024, 11:50

[SOLVED] Can't login when I create an account.

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