What strategy would you go with when implementing Linkedin auth on a website that has already registered users?

We already have a working website with registered users and I have the task to implement the LinkedIn authentication into our website and we are using MongoDB and mongoose.

I already did everything I needed to do with the Linkedin API and I am getting the email of the user who signed in with his/her LinkedIn account.
Once the user logs in, the server gets the email and check if it the user associated to that email already exists. If it exists then send the JWT token if not then create a new user and then send the JWT token, but in order to create the new user we need to have the password since it is a required field in the user schema, and we are only getting the email, first and last name, no password.

How would you go about this? Should I get rid of the password required field and then simply check if there is a password in the login and signup route? Or is there a better way to do this?

Source: Ask Javascript Questions

LEAVE A COMMENT