:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(legal-documents): suppress 403 for non-admins on /legal scene (#59230)
posthog[bot]43d80eb58820
diff --git a/products/legal_documents/frontend/scenes/legalDocumentsLogic.ts b/products/legal_documents/frontend/scenes/legalDocumentsLogic.tsindex fb1a65351d6d..e3246099135f 100644--- a/products/legal_documents/frontend/scenes/legalDocumentsLogic.ts+++ b/products/legal_documents/frontend/scenes/legalDocumentsLogic.ts@@ -3,6 +3,7 @@ import { forms } from 'kea-forms'import { loaders } from 'kea-loaders'import { router, urlToAction } from 'kea-router'+import { ApiError } from 'lib/api'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { billingLogic } from 'scenes/billing/billingLogic'import { organizationLogic } from 'scenes/organizationLogic'@@ -57,7 +58,13 @@ function defaultsFor(documentType: LegalDocumentType): LegalDocumentFormValues {export const legalDocumentsLogic = kea<legalDocumentsLogicType>([path(['products', 'legal_documents', 'legalDocumentsLogic']),connect(() => ({- values: [organizationLogic, ['currentOrganization', 'currentOrganizationId'], billingLogic, ['billing']],+ values: [+ organizationLogic,+ ['currentOrganization', 'currentOrganizationId', 'isAdminOrOwner'],+ billingLogic,+ ['billing'],+ ],+ actions: [organizationLogic, ['loadCurrentOrganizationSuccess']],})),actions({setDocumentType: (documentType: LegalDocumentType) => ({ documentType }),@@ -71,8 +78,18 @@ export const legalDocumentsLogic = kea<legalDocumentsLogicType>([if (!values.currentOrganizationId) {return []}- const response = await api.legalDocumentsList(values.currentOrganizationId)- return (response.results ?? []) as LegalDocument[]+ if (values.isAdminOrOwner === false && values.currentOrganization) {+ return []+ }+ try {+ const response = await api.legalDocumentsList(values.currentOrganizationId)+ return (response.results ?? []) as LegalDocument[]+ } catch (error) {+ if (error instanceof ApiError && error.status === 403) {+ return []+ }+ throw error+ }},},],@@ -129,6 +146,11 @@ export const legalDocumentsLogic = kea<legalDocumentsLogicType>([setDpaMode: ({ dpaMode }) => {actions.setLegalDocumentValue('dpa_mode', dpaMode)},+ loadCurrentOrganizationSuccess: () => {+ if (values.legalDocuments.length === 0 && values.isAdminOrOwner && !values.legalDocumentsLoading) {+ actions.loadLegalDocuments()+ }+ },})),selectors({hasQualifyingBaaAddon: [