0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-04-07 23:01:25 -05:00

feat(schemas): add util method to convert admin tenant org id to user tenant id ()

This commit is contained in:
Charles Zhao 2024-03-29 18:00:31 +08:00 committed by GitHub
parent a77fd3f97f
commit eb4c6c4e59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,6 +17,15 @@ import { adminTenantId } from '../seeds/tenant.js';
/** Given a tenant ID, return the corresponding organization ID in the admin tenant. */
export const getTenantOrganizationId = (tenantId: string) => `t-${tenantId}`;
/** Given an admin tenant organization ID, check the format and return the corresponding user tenant ID. */
export const getTenantIdFromOrganizationId = (organizationId: string) => {
if (!organizationId.startsWith('t-')) {
throw new Error(`Invalid admin tenant organization ID: ${organizationId}`);
}
return organizationId.slice(2);
};
/**
* Given a tenant ID, return the organization create data for the admin tenant. It follows a
* convention to generate the organization ID and name which can be used across the system.