Add sessions endpoints with queries

This commit is contained in:
2019-08-01 16:25:44 +02:00
parent ccc7a0bfb0
commit 03a9c793d8
12 changed files with 167 additions and 36 deletions

View File

@@ -9,7 +9,7 @@ router.post('/register', (req, res) => {
const hash = bcrypt.hashSync(user.password, 10);
user.password = hash;
Users.add(user)
Users.addUser(user)
.then(saved => {
res.status(201).json(saved);
})
@@ -21,7 +21,7 @@ router.post('/register', (req, res) => {
router.post('/login', (req, res) => {
let { username, password } = req.body;
Users.findBy({ username })
Users.findUserBy({ username })
.first()
.then(user => {
if (user && bcrypt.compareSync(password, user.password)) {