Back

Server Error at Client

  • 0
  • Self Hosted
  • Databases
Flyto
29 Apr, 2024, 16:22

Hello 🙂 When I am trying to create a user document in my user database during registration (any can create) it successfuly creates the document but according to the console it fails during const newDocument = await databases.createDocument(databaseId, collectionId, documentId, data); with a Error 500 and then throws an error

TypeScript
    at Client.<anonymous> (```

Logs state:
```Method: GET
2024-04-29T15:33:23.653360420Z [Error] URL: /v1/account
2024-04-29T15:33:23.653365730Z [Error] Type: Appwrite\Extend\Exception
2024-04-29T15:33:23.653371320Z [Error] Message: User (role: guests) missing scope (account)
2024-04-29T15:33:23.653376472Z [Error] File: /usr/src/code/app/controllers/shared/api.php
2024-04-29T15:33:23.653380947Z [Error] Line: 273```

Is this error due to creating a document without an active session? Can this be safely ignored or is there anyway around this/best practice how to store newAccounts in the Database?
TL;DR
Issue: Error 500 when creating a user document during registration due to a missing scope error (role: guests) in the logs when trying to create a document without an active session. Solution: - Adjust permissions to allow any for create, update, read, delete for testing purposes. - Log the user in before CRUD operations are allowed for users, guests, etc. - Format code blocks with three backticks for better readability.
Evdog
29 Apr, 2024, 16:40

Make sure to use three backticks ` to format code blocks to make it easier to read

The logs usually mean you aren't signed in

Flyto
29 Apr, 2024, 16:45

ahhh gotcha, thanks I fixed it 🙂

yeah, makes sense, but is there anything to get rid of them/another way to handle this? I am quite new to this, really appreciate your help Evan 🙂

darShan
29 Apr, 2024, 16:49
  1. make sure the permissions are correct, any for create, update, reqd, delete. this isn't secure though. fine for testing.
  2. log the user in, if the permissions only allow performing crud ops. for users, guests, etc.
Flyto
29 Apr, 2024, 16:51
  1. I only applied Create for any, not update, read, delete - just creating should be fine, is like a signup no? Or still a safety issue?
  2. Issue I am having is, I do not know how else to do it. User Data needs to be stored in the user Database. All the tutorials I found online usually create the User in the DB during the registration and store it in the DB. It makes sense to me because this way Auth Database and User Database are always synchronous. THe only alternative I can think of is checking on login if the user exists in the database and creating it if not, but that also seems quite inefficient no?
Flyto
29 Apr, 2024, 16:55

Because I want to manually confirm the users in the backend and users are not allowed to login while they are not verified...

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