Skip to content

Commit 0ccd0b6

Browse files
committed
Fix route login
1 parent c39e79b commit 0ccd0b6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ app.use(express.json());
1919
app.use('/api/user', authRoute);
2020
app.use('/api/posts', postRoute);
2121

22+
2223
app.listen(port, () => {
2324
console.log(`Server is running on port ${port}`);
2425
});

routes/auth.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ router.post('/login', async (req, res) => {
4646
// Validate the data before we make a user
4747
const {
4848
error
49-
} = RegisterValidation(req.body);
49+
} =LoginValidation(req.body);
5050
if (error) return res.status(400).send(error.details[0].message);
5151
//email exist
5252
const emailExist = await User.findOne({
@@ -55,7 +55,8 @@ router.post('/login', async (req, res) => {
5555
if (emailExist) return res.status(400).send('Email not found');
5656
//password is correct
5757
const validPass = await bcrypt.compare(req.body.password, User.password);
58-
if (!validPass) return res.status(400).send('Invalid password');
58+
if (!validPass) return res.status(400).send('Invalid password')
59+
;
5960

6061
const token = Jwt.sign({
6162
_id: User._id

0 commit comments

Comments
 (0)