Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added evidence/.DS_Store
Binary file not shown.
Binary file added evidence/original/.DS_Store
Binary file not shown.
65 changes: 65 additions & 0 deletions evidence/original/lighthouse/localhost_3000-20260511T181640.html

Large diffs are not rendered by default.

11,446 changes: 11,446 additions & 0 deletions evidence/original/lighthouse/localhost_3000-20260511T181640.json

Large diffs are not rendered by default.

144 changes: 143 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"dotenv": "^16.0.1",
"ejs": "^3.1.8",
"express": "^4.18.1"
"express": "^4.18.1",
"express-session": "^1.19.0"
}
}
46 changes: 44 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
const { urlencoded } = require("express");
const express = require("express");
const path = require("path");
const session = require("express-session");
require("dotenv").config();
require("../src/db/conn");
const requireAuth = require("./middleware/requireAuth");
const views_path = path.join(__dirname, "../views");
const static_path = path.join(__dirname, "../static");
const app = express();
app.set("etag", false);
const port = process.env.PORT || 80;

const sessionSecret =
process.env.SESSION_SECRET || "dev-only-session-secret-not-for-production";

app.use("/static", express.static(static_path));
app.use(express.json());
app.use(urlencoded({ extended: false }));
app.use(
session({
secret: sessionSecret,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
sameSite: "lax",
secure: process.env.NODE_ENV === "production",
maxAge: 1000 * 60 * 60,
},
})
);


app.set("view engine", "ejs");
Expand All @@ -25,8 +43,32 @@ app.get("/signup", (req, res) => {
res.status(200).render("signup.ejs");
});

// In Future this dashboard will be rendered after authentication of users
app.get("/dashboard", (req, res) => {
app.get("/privacy", (req, res) => {
res.status(200).render("privacy.ejs");
});

app.post("/login", (req, res) => {
const email = (req.body.LoginEmail || "").trim();
const password = (req.body.LoginPassword || "").trim();
if (!email || !password) {
return res.status(400).render("signup.ejs", {
loginError: "Email and password are required.",
});
}
req.session.user = { username: email };
return res.redirect(302, "/dashboard");
});

app.post("/logout", (req, res) => {
req.session.destroy((err) => {
if (err) {
return res.status(500).send("Could not log out.");
}
return res.redirect(302, "/");
});
});

app.get("/dashboard", requireAuth, (req, res) => {
res.status(200).render("dashboard/dashboard.ejs");
});

Expand Down
8 changes: 8 additions & 0 deletions src/middleware/requireAuth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function requireAuth(req, res, next) {
if (req.session && req.session.user) {
return next();
}
return res.redirect("/signup");
}

module.exports = requireAuth;
56 changes: 56 additions & 0 deletions static/scripts/cookie-banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function () {
var STORAGE_KEY = "taskifyCookieConsent";

function getConsent() {
try {
return window.localStorage ? window.localStorage.getItem(STORAGE_KEY) : null;
} catch (e) {
return null;
}
}

function setConsent(value) {
try {
window.localStorage && window.localStorage.setItem(STORAGE_KEY, value);
} catch (e) {
// If storage is blocked, keep the banner behavior graceful.
}
}

function showBannerIfNeeded() {
var banner = document.getElementById("taskify-cookie-banner");
if (!banner) return;

var consent = getConsent();
if (consent === "accepted" || consent === "declined") {
banner.style.display = "none";
return;
}

banner.style.display = "block";

var acceptBtn = document.getElementById("taskify-cookie-banner-accept");
var declineBtn = document.getElementById("taskify-cookie-banner-decline");

if (acceptBtn) {
acceptBtn.addEventListener("click", function () {
setConsent("accepted");
banner.style.display = "none";
});
}

if (declineBtn) {
declineBtn.addEventListener("click", function () {
setConsent("declined");
banner.style.display = "none";
});
}
}

if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", showBannerIfNeeded);
} else {
showBannerIfNeeded();
}
})();

Loading
Loading