Skip to content

onetimepassword/NodeLogin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

create the db tables

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  username VARCHAR(50) NOT NULL,
  password VARCHAR NOT NULL
);

ALTER TABLE users ADD CONSTRAINT name UNIQUE (username);

run app

npm install express body-parser bcrypt pg
node app.js

in another terminal, call service

curl -X POST -H "Content-Type: application/json" -d '{"username":"goerge", "password":"secret"}' http://localhost:8080/login
curl -X POST -H "Content-Type: application/json" -d '{"username":"goerge", "password":"secret"}' http://localhost:8080/register
curl -X POST -H "Content-Type: application/json" -d '{"username":"goerge", "password":"incorrect"}' http://localhost:8080/login
curl -X POST -H "Content-Type: application/json" -d '{"username":"goerge", "password":"secret"}' http://localhost:8080/login

with unique constraint the admin can force an update by setting the password to NULL

About

Node.js <> postgres user register and login

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published