Search code examples
node.jsmongodbexpressjwtpug

How to check if user has logged-in for the first time?


I am using Node, Express, and MongoDB for my application. I am rendering Pug Template on server side and using Json Web Tokens for login.

I want to display a specific page when user logs in for the first time. Confused how to render it only one time.

Maybe adding a field like "accountStatus" and setting status to Active or Inactive will help?


Solution

  • Save a last_login_time field on DB, it can also be used later for other logic in your app.

    If the field is empty (or not exist) display the specific page.