Fix ID issue
uriklar opened this issue · 1 comments
This the way board ids are currently generated:
username (which the user enters) + random 4 digit number
This was a very bad design choice 🤦♂️ as what can happen now is that the a user can randomly get the same 4 digit number and accidentally overwrite a previous board of his without knowing.
What I think we should do:
In the [id].tsx and index.tsx getServerSideProps we already have a query that fetches all board ids.
- call that same query in the create page.
2.I want to change the ids to be serial instead of random, so we should find the first id of this user and get the next id (need to make sure it's not taken already)
I added mock ids to the create page so you don't have to connect to firebase to work on this feature. So you can run npm test to see if it passes.
You can also add your own tests if you need..
It's on this branch:
https://github.com/uriklar/professor/compare/issue-15-fix-ids
I agree with you that is not a good choice.
Since we will add authentication to the project, every player id will be unique.
I think we can create an id from the user id and the number (nth) of the board.
For example. Marcos-1,Marcos-2 ...
What do you think ?