Loading
Bugs/560 usercode
I made some modifications to the current auth logic based on the explanation mentioend below:
- If the user enter from the landing page then go to the quiz, a new code will be generated (like it works now)
- Since we don't actually save the generated user code only after the user submits one correct answer, and we persist that code anyways in local-storage, we need a way to detect if the saved user code is registered in the db or not, se we dont get the "invalid code" error, we do so by saving a "registered" boolean in local-storage which defaulted to false, and make it true after one correct answer submitted
- Now when the user opens a new tab/session to the landing page:
- if the registered value is true in local-storage, that means only if the user code exists in db, and it didn't expire yet, we redirect him the quiz page.
- if the user code not registered, or expired, or empty at all (after logout or a first time use), we simply open the landing page and leave the input blank