Hey,
few days ago @TIMAI2 helped me with saving data to firebase, and for another app I'm making I changed it so now it saved user number, username and their password. It all works great, but I have no idea how to check if the username is already in use, any ideas on how to do it?
code:
When a user signs up, in addition to their Users> sign up data, save their username to another node, e.g. gameUsers. (this is known in firebase as denormalising, and is quite normal and accepted practice, even though it seems repetitive) You can then call back this node and test any new user name entered before it is submitted.
In your firebase rules, set up an index for "Username". You can then submit a query via a web component (REST api) to return all the usernames in a list.
But what do I do in the app inventor to search all the usernames from here and tell if there is one like the one I put already existing? Can you show me the blocks please?
Thanks a lot, it works, but it still puts you in even if the username already exists. text is shown but it still saves your username and password, it's 100% cause of a misplacement. Do you know where to put it?
Look at my example again. it needs the value from the tag "All-Usernames", you are supplying a different tag/value. You will need to put in an if/elseif to test the tag that is returned by getValue...
You will need to make sure you have your workflow running correctly, with your blocks in the correct places.
New user submits their username/password
Fetch the list if usernames from firebase
Check the new username against the returned list
If new username is in the list, then return the new user to the sign up form
If the new username is not in the list THEN submit their sign up details to Firebase, do what ever else it is you need to do with that new user
I did not test out my blocks, you therefore may need to check what is coming back from Firebase when you call the All_Usernames tag, and that the test is working for you.