From 575ef11dc76d5d96f91e0a8d7fd2011b8a75d35e Mon Sep 17 00:00:00 2001 From: fabcodingzest <48706652+fabcodingzest@users.noreply.github.com> Date: Wed, 2 Sep 2020 11:18:37 +0530 Subject: [PATCH 1/4] removed simple page layout --- helpers/getOverview.js | 2 +- routes/api/addBalance.js | 4 ++-- routes/api/cart.js | 2 +- routes/api/edit.js | 2 +- routes/api/transaction.js | 8 ++++---- routes/api/view.js | 2 +- views/layouts/simple-page.ejs | 27 --------------------------- 7 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 views/layouts/simple-page.ejs diff --git a/helpers/getOverview.js b/helpers/getOverview.js index 23dcf3a..e084b42 100644 --- a/helpers/getOverview.js +++ b/helpers/getOverview.js @@ -36,7 +36,7 @@ module.exports = async function getOverview(symbol) { })) .catch((err) => { console.log(err); - res.status(500).render("error/500", { layout: "layouts/simple-page" }); + res.status(500).render("error/500"); }); return data; diff --git a/routes/api/addBalance.js b/routes/api/addBalance.js index 3d15d61..3d3e1e7 100644 --- a/routes/api/addBalance.js +++ b/routes/api/addBalance.js @@ -47,7 +47,7 @@ router.post("/", ensureAuth, async (req, res) => { }, (err) => { if (err && err.type === "StripeCardError") { - return res.render("error/500", { layout: "layouts/simple-page" }); + return res.render("error/500"); } else { console.log("Payment Success"); } @@ -79,7 +79,7 @@ router.post("/", ensureAuth, async (req, res) => { res.redirect("/done"); } catch (err) { console.error(err); - res.render("error/500", { layout: "layouts/simple-page" }); + res.render("error/500"); } }); diff --git a/routes/api/cart.js b/routes/api/cart.js index 89c8a70..ea2fa0a 100644 --- a/routes/api/cart.js +++ b/routes/api/cart.js @@ -71,7 +71,7 @@ router.post("/buy", ensureAuth, async (req, res) => { } } catch (err) { console.error(err); - res.render("error/500", { layout: "layouts/simple-page" }); + res.render("error/500"); } }); diff --git a/routes/api/edit.js b/routes/api/edit.js index 237fb78..ff64701 100644 --- a/routes/api/edit.js +++ b/routes/api/edit.js @@ -60,7 +60,7 @@ router.put("/", ensureAuth, async (req, res) => { res.redirect("/portfolio"); } catch (err) { console.error(err); - return res.render("error/500", { layout: "layouts/simple-page" }); + return res.render("error/500"); } }); diff --git a/routes/api/transaction.js b/routes/api/transaction.js index d6ecc62..c6fce91 100644 --- a/routes/api/transaction.js +++ b/routes/api/transaction.js @@ -119,7 +119,7 @@ router.put("/confirm", ensureAuth, async (req, res) => { res.redirect("/done"); } catch (err) { console.error(err); - res.render("error/500", { layout: "layouts/simple-page" }); + res.render("error/500"); } }); @@ -159,7 +159,7 @@ router.get("/", ensureAuth, async (req, res) => { } } catch (err) { console.error(err); - res.render("error/500", { layout: "layouts/simple-page" }); + res.render("error/500"); } }); @@ -208,10 +208,10 @@ router.post("/sell/:id", ensureAuth, async (req, res) => { } }); - res.redirect("/done", { layout: "layouts/simple-page" }); + res.redirect("/done"); } catch (err) { console.error(err); - res.render("error/500", { layout: "layouts/simple-page" }); + res.render("error/500"); } }); diff --git a/routes/api/view.js b/routes/api/view.js index 7da627e..4d37b98 100644 --- a/routes/api/view.js +++ b/routes/api/view.js @@ -102,7 +102,7 @@ router.get("/:symbol", ensureAuth, async (req, res) => { }) .catch((err) => { console.error(err); - res.render("error/404", { layout: "layouts/simple-page" }); + res.render("error/404"); }); }); diff --git a/views/layouts/simple-page.ejs b/views/layouts/simple-page.ejs deleted file mode 100644 index 648d879..0000000 --- a/views/layouts/simple-page.ejs +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - TradeByte - - - - <%- body %> - - - - From ca1e95ee135acf1ec3149a9557d91c414789f7c9 Mon Sep 17 00:00:00 2001 From: fabcodingzest <48706652+fabcodingzest@users.noreply.github.com> Date: Wed, 2 Sep 2020 11:43:31 +0530 Subject: [PATCH 2/4] Done & error pages done without layout #fixed --- views/done.ejs | 209 +++++++++++++++++++++++++------------------- views/error/404.ejs | 75 +++++++++++----- views/error/500.ejs | 99 ++++++++++++++++----- views/login.ejs | 2 +- 4 files changed, 247 insertions(+), 138 deletions(-) diff --git a/views/done.ejs b/views/done.ejs index c345a62..2ffd3c5 100644 --- a/views/done.ejs +++ b/views/done.ejs @@ -1,109 +1,134 @@ - -
-
-
-

- Done -

-
- -
-
-

- Thank you for using TradeByte -

-
-
- + + + + + + + Tradebyte + + + + - + +
- +
- - - - + function toogleAddThisButtons(button) { + button.classList.toogle("showAddThisButtons"); + } + + + diff --git a/views/error/404.ejs b/views/error/404.ejs index d1104f0..9553453 100644 --- a/views/error/404.ejs +++ b/views/error/404.ejs @@ -1,27 +1,56 @@ -
-
-
-

- 4 4 -

-

PAGE NOT FOUND

-

- The page/stock you are looking for was moved or doesn't exist -

-
-
-

Let's get back

-
-
- + + + + + + TradeByte + + + + + + + +
+
+
+

+ 4 4 +

+

+ PAGE NOT FOUND +

+

+ The page/stock you are looking for was moved or doesn't exist +

+
+
+

Let's get back

+
+
+ +
+
-
-
+ + diff --git a/views/error/500.ejs b/views/error/500.ejs index 2d89498..ef0a25e 100644 --- a/views/error/500.ejs +++ b/views/error/500.ejs @@ -1,28 +1,83 @@ -
-
-
-

ERROR 500

-

- Unexpected error :( -

- -

- There seems to be a problem -

-

Let's get to back

-
-
-
- +

ERROR 500

+

+ Unexpected error :( +

+ +

+ There seems to be a problem +

+

Let's get to back

+
+
+
+ +
+
-
-
+ + diff --git a/views/login.ejs b/views/login.ejs index 0381eac..d309974 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -423,7 +423,7 @@ >

- + From 781dfb8950cb5df1cc4c4e6d92d9cfcc5d4250de Mon Sep 17 00:00:00 2001 From: fabcodingzest <48706652+fabcodingzest@users.noreply.github.com> Date: Wed, 2 Sep 2020 12:22:11 +0530 Subject: [PATCH 3/4] removed sign up validation from server side as its on client side already --- routes/api/user.js | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/routes/api/user.js b/routes/api/user.js index cc83642..4389ba1 100644 --- a/routes/api/user.js +++ b/routes/api/user.js @@ -96,31 +96,11 @@ router.post("/signup", ensureGuest, (req, res) => { // @route GET /user/signin // @access Public router.post("/signin", ensureGuest, (req, res, next) => { - const { password, email } = req.body; - let errors = []; - - if (!password || !email) { - errors.push({ msg: "Please enter all fields" }); - } - - if (password.length < 6) { - errors.push({ msg: "Password must be longer than 6 characters" }); - } - - if (errors.length > 0) { - res.render("login", { - layout: "layouts/login", - errors, - email, - password, - }); - } else { - passport.authenticate("local", { - successRedirect: "/portfolio", - failureRedirect: "/", - failureFlash: true, - })(req, res, next); - } + passport.authenticate("local", { + successRedirect: "/portfolio", + failureRedirect: "/", + failureFlash: true, + })(req, res, next); }); module.exports = router; From 316be4839488d3ff8a8c9267d337801740a9a906 Mon Sep 17 00:00:00 2001 From: fabcodingzest <48706652+fabcodingzest@users.noreply.github.com> Date: Wed, 2 Sep 2020 12:22:11 +0530 Subject: [PATCH 4/4] Removed server-side validation on the sign in as it's being done on the client-side --- routes/api/user.js | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/routes/api/user.js b/routes/api/user.js index cc83642..4389ba1 100644 --- a/routes/api/user.js +++ b/routes/api/user.js @@ -96,31 +96,11 @@ router.post("/signup", ensureGuest, (req, res) => { // @route GET /user/signin // @access Public router.post("/signin", ensureGuest, (req, res, next) => { - const { password, email } = req.body; - let errors = []; - - if (!password || !email) { - errors.push({ msg: "Please enter all fields" }); - } - - if (password.length < 6) { - errors.push({ msg: "Password must be longer than 6 characters" }); - } - - if (errors.length > 0) { - res.render("login", { - layout: "layouts/login", - errors, - email, - password, - }); - } else { - passport.authenticate("local", { - successRedirect: "/portfolio", - failureRedirect: "/", - failureFlash: true, - })(req, res, next); - } + passport.authenticate("local", { + successRedirect: "/portfolio", + failureRedirect: "/", + failureFlash: true, + })(req, res, next); }); module.exports = router;