DEV Community

Discussion on: Best way to store password in DB

Collapse
 
rhymes profile image
rhymes

I'm not a node user so I'm going to be generic. Let's start with a "shopping list" of what you might need:

  • a database to store the accounts
  • a library to connect to such database
  • a user table in the database, the minimum is probably "username", "password"
  • a library to hash those password
  • a web framework and HTML/CSS to render the registration and login pages

The registration flow is:

  • input username, password and password confirmation
  • check the two passwords, if they are equal hash one and store it in the db with the username, if they are not equal tell the user
  • redirect the user to a "success" page

The login flow is:

  • input username and password
  • hash the password and check it's the same one you have stored
  • if it is, let the user in, if not, tell them
  • redirect the user to a "success" page

This is the bare, bare, minimum.

Keep in mind that since there are no sessions in this scenario, the user will have to input their accounts everytime they decide to access the "protected" page.

Thread Thread
 
yashwanth2804 profile image
kambala yashwanth

thank you very much for getting me started.