Check if an user exist in my database with Node and MySQL

Viewed 60

This is my sandbox in the server folder there is the back-end while the front-end is in the src one. I'm using React.js and Node.js. Let's go to the point, I use Auth0 for authentication,I want to use Auth0's user_id to register users in my database in order to retrieve and update their information: e-mail, name, surname.

With Auth0 sub claim it's used to get the user_id. I would like to first check if the sub property is present in my MySQL database if true update user info with that sub else create new user record.

For example. johnsmith@gmail.com with sub: id1234 submit form

if(id1234 exist in database) {
update info;
} else {
create new user record;
}
0 Answers
Related