Home > Software engineering >  How to check if user has logged in for the first time in react js
How to check if user has logged in for the first time in react js

Time:03-02

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

CodePudding user response:

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].

CodePudding user response:

What type of form are they filling out.

I would assume you have a backend database that's storing the forms data, which in that case based on a foreign key key relationship you should be able to see if the user has filled out the forms or not. If they don't have forms you then present the forms on the front-end.

Another way to handle this is perhaps move the forms the user needs to fill out before hand into the log-in flow.

  • Related