Wire prior archive cutoff through API
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -658,7 +658,9 @@ export class AuthService {
|
||||
const membership = await this.prisma.membership.findFirst({
|
||||
where: { userId: user.id, organizationId, isActive: true },
|
||||
include: {
|
||||
organization: { select: { name: true, enabledModules: true } },
|
||||
organization: {
|
||||
select: { name: true, enabledModules: true, priorArchiveEnabledAt: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const role = membership?.role ?? user.role;
|
||||
@@ -685,13 +687,17 @@ export class AuthService {
|
||||
membership: {
|
||||
priorArchiveEnabled?: boolean;
|
||||
priorArchiveLens?: string;
|
||||
organization?: { enabledModules?: string[] };
|
||||
organization?: { enabledModules?: string[]; priorArchiveEnabledAt?: Date | null };
|
||||
} | null,
|
||||
): AuthUserDto['priorArchive'] {
|
||||
if (!membership?.priorArchiveEnabled) return undefined;
|
||||
const modules = this.billing.normalizeModules(membership.organization?.enabledModules);
|
||||
if (!modules.includes('prior_data_archive')) return undefined;
|
||||
return { lens: membership.priorArchiveLens === 'archive' ? 'archive' : 'current' };
|
||||
const orgCutoff = membership.organization?.priorArchiveEnabledAt ?? null;
|
||||
return {
|
||||
lens: membership.priorArchiveLens === 'archive' ? 'archive' : 'current',
|
||||
cutoffAt: orgCutoff ? orgCutoff.toISOString() : null,
|
||||
};
|
||||
}
|
||||
|
||||
private async throttleChallenges(
|
||||
|
||||
@@ -107,7 +107,10 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
visibleUserIds,
|
||||
scopes,
|
||||
priorLens: priorGranted ? priorLens : 'off',
|
||||
priorCutoff: priorGranted ? membership.organization.priorArchiveEnabledAt : null,
|
||||
priorCutoff:
|
||||
priorGranted && membership.organization.priorArchiveEnabledAt
|
||||
? membership.organization.priorArchiveEnabledAt
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user