The Terasology Foundation

Auto login user after registration

Prerequisites

  • NodeJs
  • Authentication using PassportJs Don't worry if you are not familiar with Passport, here's a great tutorial to start with.

Description of the problem

Auto-login is quite a popular feature currently used by almost every social networking site from Facebook to Reddit. So now coming to what the problem demands, and how we can implement this. You are supposed to make the user automatically login after he/she completes the registration(sign up) process instead of redirecting to fill the login form again.

How to solve

Sounds too complicated? Let’s focus in. You need to setup project on your end and for that follow the steps mentioned here in readme file.

First step first, find the authcontroller.js file in /server/controller and go through the code and try to understand how the signup and login function works. Get stuck somewhere or not sure what a particular statement is meant for then feel free to reach out to mentors through communication channel either on discord or slack.

Once you have gained a basic understanding of the authentication process it's time to modify the signup() and instead of just returning the response, make an implicit call to login() which will login the user and send the generated JWT token as bearer.

Acceptance Criteria

You should be able to successfully implement the auto-login feature.

Note In case you need some reference you can refer to this stackoverflow answer explaining the same.

Task tags

  • codeuino
  • passportjs
  • authentication
  • javascript

Students who completed this task

Devaa

Task type

  • code Code
close

2019