diff --git a/server/routes.ts b/server/routes.ts index 00a654d..c5124f7 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -1155,7 +1155,16 @@ export async function registerRoutes(app: Express): Promise { try { const user = req.user as User; const userId = user.id; - const pageData = insertSocialPageSchema.parse({ ...req.body, userId }); + + // Calculate token expiration date (60 days from now) + const tokenExpiresAt = new Date(); + tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 60); + + const pageData = insertSocialPageSchema.parse({ + ...req.body, + userId, + tokenExpiresAt + }); const page = await storage.createSocialPage(pageData); res.json(page); } catch (error) { diff --git a/shared/schema.ts b/shared/schema.ts index 06a6532..83a798b 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -24,6 +24,7 @@ export const socialPages = pgTable("social_pages", { pageId: text("page_id").notNull(), pageName: text("page_name").notNull(), accessToken: text("access_token").notNull(), + tokenExpiresAt: timestamp("token_expires_at"), followersCount: integer("followers_count").default(0), isActive: text("is_active").notNull().default("true"), createdAt: timestamp("created_at").defaultNow(),