First time a user logs in

I wanted to create some type of onboarding system, although I’m a complete newbie.

  1. I want to Populate data for a new signed-in user
  2. provide a link to the onboarding(complete tasks page), if they skip it, it should not appear again

Any way of doing this?

you could use beforeSave hook and a flag somewhere to test if that data was populated already

https://docs.moralis.io/moralis-server/cloud-code/triggers#beforesave

I was able to populate data, but now my issue is even if I change that data again, every time I log in it will update the previously populated data.

This is why I am trying to match the created time and the updated time then if they match: populate the data only the first time the user logs in.

Hey @tarbez

I guess in your case using a localstorage will be a nice solution. Take a look at

I’m truly lost… I have no idea what I’m doing at the moment.

  • First-time login = do something, if the createdAt matches updatedAt
  • Else just do something else
IsUserloggedFirstTime = async () =>{
    const query = new Moralis.Query("User");
    
    const UserCreatedAt = (currentUser.get('createdAt'));
    const UserUpdatedAt = (currentUser.get('updatedAt'));
    let showFirstTimeresult;
    if (UserCreatedAt == UserUpdatedAt) {
             // do something here
    } else (UserUpdatedAt > UserCreatedAt) {
         // do something here
    }

    return showFirstTimeresult;
  }

This is what I have so far.

if you get createdAt, maybe you can compare it with current time, if it is less than few seconds difference than you could say that it is recently created

That’s what I’m trying to do but not sure how to do that.
Does my code look okay or?

I don’t know, you could also use some logging with console.log