to create a new user (via email authentication) I have to allow everything in firestore, is there a better way?
match /users/{userId=**} {
allow get, list;
}
Code: I check whether the name is already taken
Future<bool> doesNameAlreadyExist(String name) async {
final QuerySnapshot result = await FirebaseFirestore.instance
.collection('users')
.where('name', isEqualTo: name)
.limit(1)
.get();
final List<DocumentSnapshot> documents = result.docs;
return documents.length == 1;
}
authentication then takes place later when the user presses the login button:
final auth = Provider.of(context)!.auth!;
String uid = await auth.createUserWithEmailAndPassword(
emailController.text,
passwordController.text,
nameController.text,
);