how to check if user already exists or signed up already

Actions & Logic

I'm working on a user signup flow in FlutterFlow and want to ensure emails are unique. I'd like to check if an entered email address already exists in my backend before creating a new user.
Users enter their email and password during signup.

  • I want to check if the email already exists in my database.

    • If it exists, I want to navigate them to a different page informing them about the duplicate email.

    • If the email doesn't exist, I want to proceed with creating the new user and navigate them to the onboarding page.

What have you tried so far?
//i have written custom action


Future<bool> newCustomAction(String? email) async {
  // QUERY firebase COLLECTION called users if email exist return true
  final QuerySnapshot<Map<String, dynamic>> result = await FirebaseFirestore
      .instance
      .collection('users')
      .where('email', isEqualTo: email)
      .get();

  debugPrint(email);
  bool isemail = result.docs.contains(email);
  debugPrint(isemail as String?);

  return result.docs.isNotEmpty;
} 
Did you check FlutterFlow's Documentation for this topic?
No
2
2 replies