Back

Getting `user_unauthorized` error while reading trying to document from the collection

  • 0
  • Databases
Vedsaga
2 Apr, 2023, 16:27

mm, thank you I guess I will add the permission while creating document... but one doubt I wonder how should I design arch, like should I create team for each business πŸ€” and then when any documents get created just link the team to that document so that other team member can access

TL;DR
User is experiencing a `user_unauthorized` error while trying to read a document from a collection. They are considering creating a function that all document creation would have to route through. They are also considering disabling document security but are unsure if that is a good solution. They mention clearing the cache and logging out to resolve the issue but are still unable to access the document. Another user suggests calling `account.get()` before fetching the document and checking for a session in the client app. User confirms that they are not logged in and realizes that they can't access the document because they created it using the console. They are advised that if document security
Vedsaga
2 Apr, 2023, 16:27

I mean this

Vedsaga
2 Apr, 2023, 16:28

for development I just added it for now

Drake
2 Apr, 2023, 16:28

Oh...if document security is disabled, the permissions on the document don't do anything

Drake
2 Apr, 2023, 16:28

Ok and?

Vedsaga
2 Apr, 2023, 16:29

I wonder then why I still can't access the document... may be I guess because I created it using console

Drake
2 Apr, 2023, 16:33

What's your code or what's the network log?

Drake
2 Apr, 2023, 16:34

So you can access the document now? But if you remove guest, you can't access the document?

Vedsaga
2 Apr, 2023, 16:34

yap correct

Vedsaga
2 Apr, 2023, 16:35

I didn't got this

Drake
2 Apr, 2023, 16:35

That means you're not logged in. There's no session

Vedsaga
2 Apr, 2023, 16:35

πŸ˜Άβ€πŸŒ«οΈ

Vedsaga
2 Apr, 2023, 16:35

let me check

Vedsaga
2 Apr, 2023, 16:35
Vedsaga
2 Apr, 2023, 16:35

it does show

Drake
2 Apr, 2023, 16:36

This is in the console. In your client app, there's no session or at least it's not being used

Vedsaga
2 Apr, 2023, 16:36

umm, let me try logging out

Drake
2 Apr, 2023, 16:36

Try calling account.get() before you fetch the document

Vedsaga
2 Apr, 2023, 16:38

I have made a appwrite service which act as centeral point of interaction between server and client

Vedsaga
2 Apr, 2023, 16:39

mm, I guess you are right now seems to be working after clearning cache

Vedsaga
2 Apr, 2023, 16:39

I wonder what approach would you suggest for this

Vedsaga
2 Apr, 2023, 16:40

or should I disable the document security which I feel is bad honestly to solve this

Drake
2 Apr, 2023, 17:28

If you require different access for different documents, you must use document level security

Drake
2 Apr, 2023, 17:29

Maybe a function to create the document where the function will put user and team in the permissions. Careful about letting the user update the document since they can update the permission to remove the team

Vedsaga
2 Apr, 2023, 17:31

if I make a function that all the document creation will have to route through it I guess, which seems not ideal I guess umm, I guess I will explain this problem in detail next Stage on next Thruday for now aim to first build logic layer for now

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