Search code examples
javascriptreactjsflowchart

How to check if user has logged in for the first time in react js


So I'm building a school matching website where users fill out a form and get matched with someone with similar information. I've completed the login and registering section. If a user registers and then logs in for the first time they should have a form to fill out. But if they're coming back and log in later on for a second time they shouldn't have to fill out a form. What are some ways to differentiate and figure out who to give a form to? Thank you


Solution

  • Don't differentiate on the basis of "has this user logged in before". Instead, focus on the actual requirement: "do we have this user's match-related details".

    You'll presumably be storing those details somewhere, so every time a user logs in, you'll need to try and retrieve their details. If none are stored for this user, present them with the form [and then store the information on it once they submit it].