Back

Label Permissions: user_unauthorized

  • 0
  • Databases
  • Flutter
  • Cloud
Red
9 Nov, 2024, 22:34

Hello I'm trying to create a document and set a label permission but It doesn't create the document just returns an error, the other permissions seem to work though

Code:

TypeScript
  @override
  Future<void> uploadContent({
    String? customId,
    required ContentModel contentModel,
  }) async {
    const String errorMessage = "Failed to upload content";
    final String documentId = customId ?? ID.unique();

    Map<dynamic, dynamic> data = contentModel.toJson()
      ..["academyId"] = uid
      ..remove("\$id")
      ..remove("\$createdAt");

    try {
      await databases.createDocument(
          databaseId: Env.databaseId,
          collectionId: Env.contentCollectionId,
          documentId: documentId,
          data: data,
          permissions: [
            Permission.read(Role.label("content")),
          ]);
    } on AppwriteException catch (e) {
      print(e);
      throw ContentException("$errorMessage: ${e.message}");
    } catch (e) {
      throw ContentException("$errorMessage: $e");
    }
  }

Error:

TypeScript
TL;DR
Developers are trying to create a document and set a label permission, but encounter an 'user_unauthorized' error. The problem is with the specific permission in the permissions list being set. Make sure the permission is one of these: any, users, user:userID, user:userID/verified, users/verified, label:educator.
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