From c3edd0d98998ed1f7164162dc3c0f19e43568f10 Mon Sep 17 00:00:00 2001
From: Federico Hurtado <fed_home@Federicos-Mac-mini.local>
Date: Mon, 14 Oct 2024 23:25:01 -0400
Subject: [PATCH] Redirect to homepage rather than sending JSON response in
 backend.

---
 backend/.env                      | 2 ++
 backend/config/auth/auth.login.js | 8 +++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/backend/.env b/backend/.env
index 7fc9cd6..b2f01e3 100644
--- a/backend/.env
+++ b/backend/.env
@@ -4,3 +4,5 @@ DB_USER=corps_directory_dev
 DB_PASSWORD=corps_db_password
 DB_NAME=corps_directory_db
 PORT=3000
+
+FRONTEND_URL=localhost:8080
\ No newline at end of file
diff --git a/backend/config/auth/auth.login.js b/backend/config/auth/auth.login.js
index 81a21c4..3fd269b 100644
--- a/backend/config/auth/auth.login.js
+++ b/backend/config/auth/auth.login.js
@@ -42,11 +42,9 @@ const casLogin = function (req, res, next) {
       // sign the token with secret key
       const token = jwt.sign(payload, JWT_SECRET, { expiresIn: "1h" });
 
-      // send the token to the frontend.
-      res.status(200).json({
-        message: "successfully authenticated.",
-        token: "token",
-      });
+      // Send the JWT token to the frontend
+      console.log("sending JWT To: ", process.env.FRONTEND_URL);
+      res.redirect(`${process.env.FRONTEND_URL}/practice?token=${token}`);
 
       console.log("Successfully authenticated and generated token.");
     });
-- 
GitLab