How do you prevent duplicate user properties in Firebase?

后端 未结 2 578
南旧
南旧 2020-11-22 02:16

I\'m Using FirebaseSimpleLogin to create users and handle authentication.

When I try and create a new user with simple login via the $createUser()

2条回答
  •  不知归路
    2020-11-22 02:56

    Wouldn't it be easier to just use the security rules to check for it's existence? I have mine set up as follows:

    "usernames": {
      "$usernameid": {
        ".read": "auth != null",
            ".write": "auth != null  && (!data.exists() || !newData.exists())"
        }
        }
    

    This allows the write if the username doesn't exist. I believe I got this directly from the Firebase docs.

提交回复
热议问题