فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
A06: enforce initialized signed-license company quota before company creation
davoodmehraban89 committed
Oct 23, 2026 at 11:12 UTC
e7cc7f012f41c63dd4d073ca627a426193923ee7
1 file changed
+10
-1
src/core/CompanyService.js
+10
-1
@@ -1,6 +1,7 @@
1
import { StorageService } from './StorageService.js';
2
import { Auth } from './Auth.js';
3
import { EventBus } from './EventBus.js';
4
+import { LicenseService } from './LicenseService.js';
5
6
const ACTIVE_KEY = 'finora_active_company';
7
const MAX_COMPANIES = 5;
@@ -47,7 +48,15 @@ class CompanyServiceImpl {
48
}
49
async create(data){
50
if(!Auth.isAdmin()) throw new Error('فقط مدیر میتواند شرکت ایجاد کند');
50
- const all=await StorageService.getAll('companies'); if(all.length>=MAX_COMPANIES) throw new Error('حداکثر ۵ شرکت مجاز است');
51
+ // Preserve pre-boot test/migration behavior, but once the offline
52
+ // entitlement service has initialized, enforce its signed quota at the
53
+ // domain boundary (not merely in a UI button).
54
+ if(LicenseService.state) LicenseService.assertWritable();
55
+ const limit=LicenseService.state
56
+ ? Math.min(MAX_COMPANIES,LicenseService.status().maxCompanies)
57
+ : MAX_COMPANIES;
58
+ const all=await StorageService.getAll('companies');
59
+ if(all.length>=limit)throw new Error('حداکثر تعداد شرکت مجاز در اشتراک تکمیل شده است');
60
return StorageService.put('companies',{...data,id:StorageService.uid('cmp_'),ownerUserId:Auth.current().id});
61
}
62
async _migrateLegacy(defaultCompanyId){