This commit is contained in:
newtbot
2024-01-18 03:15:31 +08:00
parent 1ddce4b743
commit 4e4e8bfee2
7 changed files with 268 additions and 113 deletions

View File

@ -14,19 +14,12 @@ router.get("/", async (req, res, next) => {
}
});
/*
1) req.body is taken from html form or wtv
2) bcrpyt and hash the password on the server side
3) pass to db
*/
router.post("/new", async (req, res, next) => {
// /user/register
router.post("/register", async (req, res, next) => {
try {
//pass pass to hashPassword
let hash = await hashPassword(req.body.password);
//add hash back to req.body
req.body.password = hash;
await addUser(req.body);
res.sendStatus(200);
console.log(req.body);
//await addUser(req.body);
//res.sendStatus(200);
} catch (error) {
console.error(error);
next(error);