Answer the question
In order to leave comments, you need to log in
What does req.body.username do?
What does req.body.username do in this code?
var Schedule = require("../models/schedule");
router.post("/", async function(req, res, next) {
let user;
if (req.body.username != null) {
user = await Schedule.findOne({
owner: {
name: req.body.username,
password: req.body.password
}
});
if (user === null) {
res.redirect('/register');
}
res.redirect(`/user/${req.body.username}`);
}
});
Answer the question
In order to leave comments, you need to log in
Checks if there is a username value in the post request)
If it is in the top if = finds the username and password in the database
Yes = goes to the profile page,
No = goes to the registration page.
Regular login form in express
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question