From e1edcf20543481adb3476e6c9b3e3dc71054caa4 Mon Sep 17 00:00:00 2001 From: tylrx404 Date: Tue, 23 Jun 2026 23:54:53 +0530 Subject: [PATCH 1/3] fix: hash passwords using bcrypt for secure authentication --- server.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 13aab53f..92d12111 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ require('dotenv').config(); const express = require('express'); const cors = require('cors'); +const bcrypt = require('bcrypt'); const { db, initDb } = require('./database'); const { GoogleGenAI } = require('@google/genai'); const path = require('path'); @@ -555,7 +556,7 @@ Text: "${text}" // ================= AUTH ================= // SIGNUP -app.post('/api/auth/signup', (req, res) => { +app.post('/api/auth/signup', async(req, res) => { const { email, password } = req.body; if (!email || !password) { @@ -566,10 +567,11 @@ app.post('/api/auth/signup', (req, res) => { const id = 'user_' + Date.now(); + const hashedPassword = await bcrypt.hash(password, 10); db.run( `INSERT INTO users (id, email, password) VALUES (?, ?, ?)`, - [id, email, password], + [id, email, hashedPassword], function(err) { if (err) { @@ -594,7 +596,7 @@ app.post('/api/auth/signup', (req, res) => { }); // LOGIN -app.post('/api/auth/login', (req, res) => { +app.post('/api/auth/login',async (req, res) => { const { email, password } = req.body; if (!email || !password) { @@ -606,7 +608,7 @@ app.post('/api/auth/login', (req, res) => { db.get( `SELECT * FROM users WHERE email = ?`, [email], - (err, user) => { + async (err, user) => { if (err) { return res.status(500).json({ @@ -614,12 +616,21 @@ app.post('/api/auth/login', (req, res) => { }); } - if (!user || user.password !== password) { + if (!user) { return res.status(401).json({ error: 'Invalid email or password' }); } + const isValid = await bcrypt.compare( + password, + user.password + ); + if (!isValid) { + return res.status(401).json({ + error: 'Invalid email or password' + }); + } res.json({ success: true, email: user.email From 90d3f99046bf8e35e53e650d54011ebbf1f335e5 Mon Sep 17 00:00:00 2001 From: tylrx404 Date: Wed, 24 Jun 2026 16:24:58 +0530 Subject: [PATCH 2/3] fix: add previous month navigation for calendar --- js/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index ccec3408..b8b679aa 100644 --- a/js/app.js +++ b/js/app.js @@ -1408,7 +1408,10 @@ document.addEventListener('DOMContentLoaded', () => { renderFocusTasks(); }); } - + document.getElementById('cal-prev').addEventListener('click', () => { + currentMonthDate.setMonth(currentMonthDate.getMonth() - 1); + renderCalendar(); + }); document.getElementById('cal-next').addEventListener('click', () => { currentMonthDate.setMonth(currentMonthDate.getMonth() + 1); renderCalendar(); From 6c03252143d9bdc596bbe2fed5e46d5de3710500 Mon Sep 17 00:00:00 2001 From: tylrx404 Date: Thu, 25 Jun 2026 23:21:36 +0530 Subject: [PATCH 3/3] fix: correctly parse ISO date format YYYY-MM-DD --- js/utils/nlpDateExtractor.js | 10 ++++++++++ server.js | 25 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/js/utils/nlpDateExtractor.js b/js/utils/nlpDateExtractor.js index e6d23c92..1084fa4f 100644 --- a/js/utils/nlpDateExtractor.js +++ b/js/utils/nlpDateExtractor.js @@ -161,6 +161,16 @@ function matchAbsoluteDate(lower, now) { return toISO(startOf(resolveYear(now, month, day))); } + m = lower.match(/\b(\d{4})[\/\-\.](\d{1,2})[\/\-\.](\d{1,2})\b/); + + if (m) { + const year = parseInt(m[1]); + const month = parseInt(m[2]) - 1; + const day = parseInt(m[3]); + + return toISO(startOf(new Date(year, month, day))); + } + m = lower.match(/\b(\d{1,2})[\/\-\.](\d{1,2})(?:[\/\-\.](\d{2,4}))?\b/); if (m) { const day = parseInt(m[1]); diff --git a/server.js b/server.js index 92d12111..974e22ac 100644 --- a/server.js +++ b/server.js @@ -75,12 +75,12 @@ const NLP_MONTHS = { oct:9,october:9,nov:10,november:10,dec:11,december:11 }; -function nlpResolveYear(now, month, day, explicitYear = null) { - if (explicitYear) return new Date(explicitYear, month, day); - const c = new Date(now.getFullYear(), month, day); - if (c < now) c.setFullYear(c.getFullYear() + 1); - return c; -} + function nlpResolveYear(now, month, day, explicitYear = null) { + if (explicitYear) return new Date(explicitYear, month, day); + const c = new Date(now.getFullYear(), month, day); + if (c < now) c.setFullYear(c.getFullYear() + 1); + return c; + } function nlpExtractDate(text, now = new Date()) { const lower = text.toLowerCase(); @@ -118,6 +118,19 @@ function nlpExtractDate(text, now = new Date()) { m = lower.match(new RegExp(`\\b${ord}\\s+(${monthNames})\\b`)); if (m) return nlpWithTime(nlpStartOf(nlpResolveYear(now, NLP_MONTHS[m[2]], parseInt(m[1]))).toISOString(), time); + m = lower.match(/\b(\d{4})[\/\-\.](\d{1,2})[\/\-\.](\d{1,2})\b/); + + if (m) { + const year = parseInt(m[1]); + const month = parseInt(m[2]) - 1; + const day = parseInt(m[3]); + + return nlpWithTime( + nlpStartOf(new Date(year, month, day)).toISOString(), + time + ); + } + m = lower.match(/\b(\d{1,2})[\/\-\.](\d{1,2})(?:[\/\-\.](\d{2,4}))?\b/); if (m) { const day = parseInt(m[1]), month = parseInt(m[2]) - 1;