|
|
@ -97,7 +97,11 @@ const getProot = () => |
|
|
|
} |
|
|
|
|
|
|
|
const user = await User.findOne({ username: req.body.username }); |
|
|
|
const valid = await bcrypt.compare(req.body.password, user.password); |
|
|
|
if (user) { |
|
|
|
const valid = await bcrypt.compare( |
|
|
|
req.body.password, |
|
|
|
user.password, |
|
|
|
); |
|
|
|
|
|
|
|
if (valid) { |
|
|
|
const token = uuid(); |
|
|
@ -105,6 +109,19 @@ const getProot = () => |
|
|
|
await user.save(); |
|
|
|
|
|
|
|
res.send({ success: true, token }); |
|
|
|
} else { |
|
|
|
res.statusCode = 401; |
|
|
|
res.send({ |
|
|
|
success: false, |
|
|
|
msg: "Error! Username or password was wrong.", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
res.statusCode = 401; |
|
|
|
res.send({ |
|
|
|
success: false, |
|
|
|
msg: "Error! Username or password was wrong.", |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|