0

We are validating user by Rest API if user is valid then Rest call will return one cookie object that include some token and then we have to redirect user to another url so by setting header with that cookie so that user will be able to login automatically without prompting login window. How we can do this thing, we are using Node JS

1 Answers1

0

From my understanding of your question, you wish to authenticate a user and redirect them to another url when they've been authenticated. If so, you can try using sessions.

With sessions, you can securely store cookie variables for a period of time that you can check for on your pages that require user login. That way, pages that require authentication can be loaded without prompting the login window/page. An example of a variable you can set would be isUserLoggedIn: true.

Here's a tutorial for using sessions with Express.js.

Jackson
  • 53
  • 1
  • 8
  • Thanks for your answer but here problem is both url is from different domain so we need to set cookies for different domain URL – Pawan Kumar Sharma Mar 09 '20 at 03:32
  • This might not be the best approach but I think it will work. Since authentication across your two domains is determined by calling your REST API, I presume you have a database set up to store your users. If so, you could update an attribute on your user to indicate their logged-in status an query/update that on page load/exit. – Jackson Mar 11 '20 at 05:44