Refactor task formatting and extend session cookie expiration to one month
This commit is contained in:
@@ -15,16 +15,15 @@ if (!fs.existsSync(dataDir)) {
|
|||||||
// Ensure the tags.json file exists
|
// Ensure the tags.json file exists
|
||||||
const tagsFilePath = path.join(dataDir, 'tags.json');
|
const tagsFilePath = path.join(dataDir, 'tags.json');
|
||||||
if (!fs.existsSync(tagsFilePath)) {
|
if (!fs.existsSync(tagsFilePath)) {
|
||||||
fs.writeFileSync(tagsFilePath, JSON.stringify([]));
|
fs.writeFileSync(tagsFilePath, JSON.stringify([]));}
|
||||||
}
|
|
||||||
|
|
||||||
// Protect the /add-task endpoint with authentication
|
// Protect the /add-task endpoint with authentication
|
||||||
router.post('/add-task', auth, async (req, res) => {
|
router.post('/add-task', auth, async (req, res) => {
|
||||||
const { subject, description, scheduled } = req.body;
|
const { subject, description, scheduled } = req.body;
|
||||||
const currentDateTime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
const currentDateTime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
||||||
|
|
||||||
let orgFormattedData = `
|
let orgFormattedData = `* TODO ${subject}
|
||||||
* TODO ${subject}
|
|
||||||
SCHEDULED: <${scheduled}>
|
SCHEDULED: <${scheduled}>
|
||||||
:LOGBOOK:
|
:LOGBOOK:
|
||||||
- State "TODO" from "TODO" [${currentDateTime}]
|
- State "TODO" from "TODO" [${currentDateTime}]
|
||||||
@@ -32,8 +31,7 @@ router.post('/add-task', auth, async (req, res) => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
if (description) {
|
if (description) {
|
||||||
orgFormattedData = `
|
orgFormattedData = `* TODO ${subject}
|
||||||
* TODO ${subject}
|
|
||||||
${description}
|
${description}
|
||||||
SCHEDULED: <${scheduled}>
|
SCHEDULED: <${scheduled}>
|
||||||
:LOGBOOK:
|
:LOGBOOK:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ app.use(session({
|
|||||||
secret: process.env.SESSION_SECRET || 'default_secret', // Use a strong secret in production
|
secret: process.env.SESSION_SECRET || 'default_secret', // Use a strong secret in production
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: 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);
|
app.use('/', authRouter);
|
||||||
|
|||||||
Reference in New Issue
Block a user