Update token expiration to 90 days and recalculate upon update

Adjusted access token expiration to 90 days in POST and PUT routes, updating shared/schema.ts and client/src/pages/pages.tsx.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 9b68577b-34d3-49be-8a1f-69c8bcb3cdb3
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/5aomXd9
This commit is contained in:
michaelschal committed 2025-11-17 15:38:55 +00:00
1 parent 983ba33a9d
commit 1f58e88d30
2 files changed
+12 -4

No files matched your search

+11 -3
View File
@@ -1156,9 +1156,9 @@ export async function registerRoutes(app: Express): Promise<Server> {
const user = req.user as User;
const userId = user.id;
// Calculate token expiration date (60 days from now)
// Calculate token expiration date (90 days from now)
const tokenExpiresAt = new Date();
tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 60);
tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 90);
const pageData = insertSocialPageSchema.parse({
...req.body,
@@ -1184,7 +1184,15 @@ export async function registerRoutes(app: Express): Promise<Server> {
return res.status(404).json({ error: "Page non trouvée" });
}
const pageData = insertSocialPageSchema.partial().parse(req.body);
let pageData = insertSocialPageSchema.partial().parse(req.body);
// If accessToken is being updated, recalculate expiration date (90 days from now)
if (pageData.accessToken) {
const tokenExpiresAt = new Date();
tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 90);
pageData = { ...pageData, tokenExpiresAt };
}
const updatedPage = await storage.updateSocialPage(pageId, pageData);
res.json(updatedPage);
} catch (error) {