Back

Creating Document with Relationship resulting error The current user is not authorized to perform

  • 1
  • Databases
  • Web
  • Cloud
Bijit !! Bijit-Mondal
28 Mar, 2024, 17:16

I have user collection having user details like Table user { user_id integer name string profession string user_qualification ( relationship with user_qualification ) }

I have a qualification collection Table qualification{ qualification_id integer qualification_name string }

and I have user_qualification table

Table user_qualification{ user_id integer (two way relationship with user collection) qualification_id integer ( one way relationship with collection) }

Now I want to allow user to self assign them qualification

so I am having this createDocument call

TypeScript
const addUserQualification = async (req) => {
    try{
      const userStore = useUserStore()
      return await databases.createDocument(
          appwriteConfig.databaseId,
          appwriteConfig.userQualificationsCollectionId,
          ID.unique(),
          {
            user: userStore.user,
            qualification: req
          }
      )
    }catch (e){
      throw e
    }
}

I am using pinia store, and userStore.user return full user object and req is qualification object. But though user have permission to create and update document

AppwriteException: The current user is not authorized to perform the requested action

TL;DR
Developers are trying to allow users to assign qualifications to themselves by creating a document with a relationship, but are facing an authorization error. Despite having permission to create and update documents, they are still unable to perform the action. Solution: Check the user's permissions for creating and updating documents in the Appwrite database, ensuring that the necessary authorization settings are correctly configured.
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