Skip to content

Commit c92a416

Browse files
fix(trust): old org upload certificate problems (#1871)
Co-authored-by: Tofik Hasanov <annexcies@gmail.com>
1 parent 490b15a commit c92a416

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

apps/api/src/trust-portal/trust-portal.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,22 @@ export class TrustPortalService {
345345
);
346346
}
347347

348-
if (!trustRecord[config.enabledField]) {
348+
if (trustRecord[config.statusField] !== 'compliant') {
349349
throw new BadRequestException(
350-
`Framework ${framework} is not enabled for this organization`,
350+
`Framework ${framework} must be marked as compliant before uploading a certificate`,
351351
);
352352
}
353353

354-
if (trustRecord[config.statusField] !== 'compliant') {
355-
throw new BadRequestException(
356-
`Framework ${framework} must be marked as compliant before uploading a certificate`,
354+
// Auto-enable the framework if it's not already enabled (for backward compatibility with old organizations)
355+
if (!trustRecord[config.enabledField]) {
356+
await db.trust.update({
357+
where: { organizationId },
358+
data: {
359+
[config.enabledField]: true,
360+
},
361+
});
362+
this.logger.log(
363+
`Auto-enabled framework ${framework} for organization ${organizationId} during certificate upload`,
357364
);
358365
}
359366
}

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)