MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / isCompliant

Method isCompliant

src/services/mdm/MdmService.ts:62–114  ·  view source on GitHub ↗

* Check if the current state is compliant with MDM policy

()

Source from the content-addressed store, hash-verified

60 * Check if the current state is compliant with MDM policy
61 */
62 public isCompliant(): ComplianceResult {
63 // If no MDM policy, always compliant
64 if (!this.requiresCloudAuth()) {
65 return { compliant: true }
66 }
67
68 // Check if cloud service is available and has active or attempting session
69 if (!CloudService.hasInstance() || !CloudService.instance.hasOrIsAcquiringActiveSession()) {
70 return {
71 compliant: false,
72 reason: t("mdm.errors.cloud_auth_required"),
73 }
74 }
75
76 // Check organization match if specified
77 const requiredOrgId = this.getRequiredOrganizationId()
78 if (requiredOrgId) {
79 try {
80 // First try to get from active session
81 let currentOrgId = CloudService.instance.getOrganizationId()
82
83 // If no active session, check stored credentials
84 if (!currentOrgId) {
85 const storedOrgId = CloudService.instance.getStoredOrganizationId()
86
87 // null means personal account, which is not compliant for org requirements
88 if (storedOrgId === null || storedOrgId !== requiredOrgId) {
89 return {
90 compliant: false,
91 reason: t("mdm.errors.organization_mismatch"),
92 }
93 }
94
95 currentOrgId = storedOrgId
96 }
97
98 if (currentOrgId !== requiredOrgId) {
99 return {
100 compliant: false,
101 reason: t("mdm.errors.organization_mismatch"),
102 }
103 }
104 } catch (error) {
105 this.log("[MDM] Error checking organization ID:", error)
106 return {
107 compliant: false,
108 reason: t("mdm.errors.verification_failed"),
109 }
110 }
111 }
112
113 return { compliant: true }
114 }
115
116 /**
117 * Load MDM configuration from system location

Callers 2

checkMdmComplianceMethod · 0.80
MdmService.spec.tsFile · 0.80

Calls 8

requiresCloudAuthMethod · 0.95
tFunction · 0.90
getOrganizationIdMethod · 0.80
logMethod · 0.65
hasInstanceMethod · 0.45

Tested by

no test coverage detected