Skip to content

Commit

Permalink
Add: login feature
Browse files Browse the repository at this point in the history
  • Loading branch information
linoxolus committed Aug 14, 2023
1 parent a07346d commit c95752a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/app/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@ const users = require('../models/User.model');
class authController {
// [POST] /auth/login
login(req, res, next) {
console.log(req.body);
const { username, password } = req.body;
users.findOne({ username })
.then((user) => {
if(!username || !password) {
return res.status(400).json({
message: "Username or Password not present"
})
} else {
if (user.password === password) {
res.redirect('https://github.com/linoxolus');
} else {
res.status(400).json({
message: "Login Failed"
})
}
}
})
}

// [POST] /auth/register
Expand Down

0 comments on commit c95752a

Please sign in to comment.