mirror of
https://gitlab.com/nekoya/web.git
synced 2024-11-13 01:46:23 +01:00
Add error handler for product page
This commit is contained in:
parent
f209037436
commit
43e8497d67
1 changed files with 24 additions and 16 deletions
|
@ -180,24 +180,32 @@ router.get("/products", (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/product/:id", (req, res) => {
|
router.get(["/product", "/product/:id"], (req, res) => {
|
||||||
auth.session_converter(req.cookies.session_token).then((key) => {
|
if (!req.params.id) {
|
||||||
if (key != null) {
|
auth.session_converter(req.cookies.session_token).then((key) => {
|
||||||
controller.getProduct(req.params.id).then((data) => {
|
if (key != null) {
|
||||||
res.render("pages/product", {
|
controller.getProduct(req.params.id).then((data) => {
|
||||||
data: data,
|
if (data != undefined) {
|
||||||
loggedIn: 'true'
|
res.render("pages/product", {
|
||||||
|
data: data,
|
||||||
|
loggedIn: 'true'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.redirect("/products");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
controller.getProduct(req.params.id).then((data) => {
|
||||||
controller.getProduct(req.params.id).then((data) => {
|
res.render("pages/product", {
|
||||||
res.render("pages/product", {
|
data: data,
|
||||||
data: data,
|
loggedIn: 'false'
|
||||||
loggedIn: 'false'
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
} else {
|
||||||
|
res.redirect("/products")
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/bag", (req, res) => {
|
router.get("/bag", (req, res) => {
|
||||||
|
|
Loading…
Reference in a new issue