Add sessions endpoints with queries
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user