Back

Authentication not working.

  • 0
  • Cloud
codehack_01
8 Jun, 2024, 15:27

Hello team…

I had a project built sometimes ago which works just fine both in development and production As time goes by, I discovered users couldn’t login nor sign up anymore, users details gets stored in the database, but my app just doesn’t proceed to home page.

I had the following code and console error:

export async function signInAccount(user: {email: string; password: string;}) { try{ const session = await account.createEmailSession(user.email, user.password); return session; } catch (error) { console.log(error) } }

This code returned “Creation of a session is prohibited when a session is active”

I did some research and replaced with the following code:

export async function signInAccount(user: {email: string; password: string;}) { try{ await account.deleteSessions(); const session = await account.createEmailSession(user.email, user.password); return session; } catch (error) { console.log(error); } }

Now…the new code throws an error “Appwrite is using local storage for session management, increase your security by adding a custom domain in your API endpoint” I huge the team to support.

TL;DR
Developers facing authentication issue where users can't login. Initially tried creating session but faced error related to active session. Modified code to delete sessions before creating new one, but now getting error about needing custom domain for session management. Requesting team's support.
Steven
8 Jun, 2024, 15:31

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Steven
8 Jun, 2024, 15:33

Are you requiring users to always log in? And you're not checking if they're logged in on app start?

codehack_01
8 Jun, 2024, 15:39

There’s a check for that And everything worked just fine when i first launched If a user is logged in, they don’t have to login again, long as the session is still active. I’ve tried on new devices I’ve never logged in to, but still the same error

Steven
8 Jun, 2024, 15:46

Would you please check the request details for the failed request and look at the request headers

codehack_01
8 Jun, 2024, 15:47

I’ll do just that and get back in few minutes

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