Fijar trial a 14 días en alta de tenant y reforzar filtro por tenant en escrituras
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { db } from './index';
|
||||
import { users, tenants } from './schema';
|
||||
import { sessionExpiry } from '@/lib/auth/tokens';
|
||||
|
||||
const TRIAL_MS = 14 * 24 * 60 * 60 * 1000;
|
||||
|
||||
export async function getUserByEmail(email: string) {
|
||||
const [row] = await db.select().from(users).where(eq(users.email, email)).limit(1);
|
||||
@@ -28,7 +29,7 @@ export async function createTenantWithOwner(input: {
|
||||
nombreEmpresa: input.nombreEmpresa,
|
||||
provincia: input.provincia,
|
||||
subscriptionStatus: 'trial',
|
||||
trialEndsAt: sessionExpiry(new Date()),
|
||||
trialEndsAt: new Date(Date.now() + TRIAL_MS),
|
||||
})
|
||||
.returning();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user