diff --git a/routes/tasks.js b/routes/tasks.js index 88fa183..03daf64 100644 --- a/routes/tasks.js +++ b/routes/tasks.js @@ -15,31 +15,29 @@ if (!fs.existsSync(dataDir)) { // Ensure the tags.json file exists const tagsFilePath = path.join(dataDir, 'tags.json'); if (!fs.existsSync(tagsFilePath)) { - fs.writeFileSync(tagsFilePath, JSON.stringify([])); -} + fs.writeFileSync(tagsFilePath, JSON.stringify([]));} + // Protect the /add-task endpoint with authentication router.post('/add-task', auth, async (req, res) => { const { subject, description, scheduled } = req.body; const currentDateTime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); - let orgFormattedData = ` -* TODO ${subject} + let orgFormattedData = `* TODO ${subject} SCHEDULED: <${scheduled}> :LOGBOOK: - State "TODO" from "TODO" [${currentDateTime}] :END: - `; +`; if (description) { - orgFormattedData = ` -* TODO ${subject} + orgFormattedData = `* TODO ${subject} ${description} SCHEDULED: <${scheduled}> :LOGBOOK: - State "TODO" from "TODO" [${currentDateTime}] :END: - `; +`; } const filePath = path.join(dataDir, 'tasks.org'); diff --git a/server.js b/server.js index 7387e5a..e4b385e 100644 --- a/server.js +++ b/server.js @@ -20,7 +20,7 @@ app.use(session({ secret: process.env.SESSION_SECRET || 'default_secret', // Use a strong secret in production resave: false, saveUninitialized: false, - cookie: { secure: false, maxAge: 24 * 60 * 60 * 1000 } // 1 day + cookie: { secure: false, maxAge: 30 * 24 * 60 * 60 * 1000 } // 1 month })); app.use('/', authRouter);