From 2193a7aad730f2dd6f3d2c50953d55e8877c751c Mon Sep 17 00:00:00 2001 From: Yash Ainapure Date: Thu, 7 Dec 2023 16:44:33 +0530 Subject: [PATCH 1/2] Renaming /submit routes --- app.js | 9 +++++---- views/{submit.ejs => secret-form.ejs} | 2 +- views/secrets.ejs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename views/{submit.ejs => secret-form.ejs} (90%) diff --git a/app.js b/app.js index 2756b20..6cd79c7 100644 --- a/app.js +++ b/app.js @@ -161,15 +161,16 @@ app.get("/secrets", function (req, res) { }); }); -app.get("/submit", function (req, res) { +app.get("/submit-secret-form", function (req, res) { if (req.isAuthenticated()) { - res.render("submit"); + res.render("secret-form"); } else { - res.redirect("/login"); + res.render("secret-form"); + //res.redirect("/login"); } }); -app.post("/submit", function (req, res) { +app.post("/submit-secret-form", function (req, res) { const submittedSecret = req.body.secret; User.findById(req.user.id, function (err, foundUser) { if (err) { diff --git a/views/submit.ejs b/views/secret-form.ejs similarity index 90% rename from views/submit.ejs rename to views/secret-form.ejs index 477fddc..26b4fa3 100644 --- a/views/submit.ejs +++ b/views/secret-form.ejs @@ -6,7 +6,7 @@

Secrets

Don't keep your secrets, share them anonymously!

-
+
diff --git a/views/secrets.ejs b/views/secrets.ejs index 8093def..bb25467 100644 --- a/views/secrets.ejs +++ b/views/secrets.ejs @@ -15,7 +15,7 @@
From bd81ad69c422da5c1364b61b2cb28707f12a86ee Mon Sep 17 00:00:00 2001 From: Yash Ainapure Date: Thu, 7 Dec 2023 16:48:42 +0530 Subject: [PATCH 2/2] changes made in /submit route name chnaging --- app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app.js b/app.js index 6cd79c7..97a6681 100644 --- a/app.js +++ b/app.js @@ -165,8 +165,7 @@ app.get("/submit-secret-form", function (req, res) { if (req.isAuthenticated()) { res.render("secret-form"); } else { - res.render("secret-form"); - //res.redirect("/login"); + res.redirect("/login"); } });