Skip to content

Commit

Permalink
[🛠️] fixed signup issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Codewith-ARK committed Mar 29, 2024
1 parent a3f643b commit dca2131
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,21 @@ router.get("/register", (req, res)=>{
res.sendFile(path.join(__dirname, "public", "pages", "register.html"))
});

router.post("/register", (req, res) => {
router.post("/register", async (req, res) => {
// parse data from the user response
const newUserData = {
email: req.sanitize(req.body.email),
password: req.sanitize(req.body.password),
full_name: req.sanitize(req.body.fullName),
};
// create a new user document from the user response
utility.createUser(newUserData);
// redirect the user to login page
res.status(200).redirect("/success");
try {
// create a new user document from the user response
await utility.createUser(newUserData);
// redirect the user to login page
res.status(200).redirect("/success");
} catch(err){
console.error("Error creating user:",err.message)
}
});

router.get("/dashboard", (req, res)=>{
Expand Down

0 comments on commit dca2131

Please sign in to comment.