Hello FlutterFlow Community,
I’m working on setting up solid Firestore Rules for my new company web app. While FlutterFlow may not be ideal for web apps, I’m using it for a Proof of Concept (POC). Nevertheless, it’s crucial that the rules are solid. I started by setting up the rules within FlutterFlow, and then I enhanced those rules manually in the Firestore Rules Console.
Currently, I’m stuck on the rule for creating user documents. In my company platform, each company operates in its own ecosystem, with no interaction between different companies or their users. Users cannot create accounts themselves; they must first be created by an admin within the app. After creation, users can log in on their own. Each user document includes a reference to the company they belong to, and each company document has a users_list field that stores user document IDs (not references, just their ID as a string).
What I’m Trying to Achieve:
A user should only be allowed to create another user if the creating user is listed in the users_list of the company that is referenced in the companyid field of the user being created. Additionally, the creating user must have their is_admin field set to true.
Since I’ve been encountering errors, I’ve temporarily commented out the entire rule and am now trying to fix it line by line. This post focuses specifically on the rule that checks whether the creating user is listed in the users_list of the companyid of the user being created.