-
Notifications
You must be signed in to change notification settings - Fork 316
CS-413 [BUG] SoA shows "unavailable" to auditor account #2925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dd5a801
38e1cdb
c1e6215
0256e81
a874249
5108839
eace526
ee5ff4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,6 +319,47 @@ export class SOAService { | |
| return { success: true, configuration, document }; | ||
| } | ||
|
|
||
| async getSetup(dto: EnsureSOASetupDto) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents |
||
| const framework = await db.frameworkEditorFramework.findUnique({ | ||
| where: { id: dto.frameworkId }, | ||
| }); | ||
|
|
||
| if (!framework) { | ||
| throw new NotFoundException('Framework not found'); | ||
| } | ||
|
|
||
| const isISO27001 = ISO27001_FRAMEWORK_NAMES.includes(framework.name); | ||
|
|
||
| if (!isISO27001) { | ||
| return { | ||
| success: false, | ||
| error: 'Only ISO 27001 framework is currently supported', | ||
| configuration: null, | ||
| document: null, | ||
| }; | ||
| } | ||
|
|
||
| const configuration = await db.sOAFrameworkConfiguration.findFirst({ | ||
| where: { | ||
| frameworkId: dto.frameworkId, | ||
| isLatest: true, | ||
| }, | ||
| }); | ||
|
|
||
| const document = await db.sOADocument.findFirst({ | ||
| where: { | ||
| frameworkId: dto.frameworkId, | ||
| organizationId: dto.organizationId, | ||
| isLatest: true, | ||
| }, | ||
| include: { | ||
| answers: { where: { isLatestAnswer: true } }, | ||
| }, | ||
| }); | ||
|
|
||
| return { success: true, configuration, document }; | ||
| } | ||
|
|
||
| async approveDocument(dto: ApproveSOADocumentDto, userId: string) { | ||
| const member = await this.validateOwnerOrAdmin(dto.organizationId, userId); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { serverApi } from '@/lib/api-server'; | ||
| import { parseRolesString } from '@/lib/permissions'; | ||
| import { hasPermission, parseRolesString } from '@/lib/permissions'; | ||
| import { resolveCurrentUserPermissions } from '@/lib/permissions.server'; | ||
| import { auth } from '@/utils/auth'; | ||
| import { Breadcrumb, PageLayout } from '@trycompai/design-system'; | ||
| import { headers } from 'next/headers'; | ||
|
|
@@ -90,12 +91,19 @@ export default async function StatementOfApplicabilityPage({ | |
| try { | ||
| const { frameworkId, framework } = isoFrameworkInstance; | ||
|
|
||
| const userPermissions = await resolveCurrentUserPermissions(organizationId); | ||
| const canCreateSetup = | ||
| !!userPermissions && hasPermission(userPermissions, 'audit', 'create'); | ||
| const setupEndpoint = canCreateSetup | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Using Prompt for AI agents |
||
| ? '/v1/soa/ensure-setup' | ||
| : '/v1/soa/get-setup'; | ||
|
|
||
| const setupResult = await serverApi.post<{ | ||
| success: boolean; | ||
| error?: string; | ||
| configuration: Record<string, unknown> | null; | ||
| document: Record<string, unknown> | null; | ||
| }>('/v1/soa/ensure-setup', { frameworkId, organizationId }); | ||
| }>(setupEndpoint, { frameworkId, organizationId }); | ||
|
|
||
| const setupData = setupResult.data; | ||
| if (!setupData?.success) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.