Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
lata-11 committed Jan 17, 2023
1 parent 407c8da commit 20696b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Technova/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ app.get("/logout", (req, res) => {

app.get("/:id/dashboard", requireLogin, async (req,res)=>{
const id = req.params.id;
const user= await User.findOne({ id});
const user= await User.findOne({ name:id});
if(req.session.user_id ==user._id)
res.render("dashboard", { user });
else
{
res.send("Permission denied");
}
})
app.get("/:id/book", requireLogin, async (req,res)=>{
const id = req.params.id;
const user= await User.findOne({ id});
const user= await User.findOne({name: id});
res.render("ticket", {user});
})

Expand All @@ -103,7 +108,7 @@ app.post("/:id/book", requireLogin, async(req,res)=>{
});
await ticket_booked.save();

res.redirect(`/${id}/dashboard`,{user})
res.redirect(`/${id}/dashboard`)
}catch (e) {
req.flash("error", e.message);
res.render("login");
Expand All @@ -124,7 +129,7 @@ app.post("/signup", async (req, res) => {
await user.save();
req.session.user_id = user._id;
req.flash("success", "Successfully registered");
res.redirect("dashboard");
res.redirect("/login");
} catch (e) {
req.flash("error", e.message);
res.redirect("/signup");
Expand Down

0 comments on commit 20696b7

Please sign in to comment.