mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-31 20:58:05 +00:00
Refactor: Replace organization ID with customer ID in data models and access methods.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/55bdac1c-eb79-41e7-a716-be82bfbdddcd.jpg
This commit is contained in:
+12
-6
@@ -342,9 +342,9 @@ export class MemStorage implements IStorage {
|
|||||||
return this.domainsMap.get(parseInt(id));
|
return this.domainsMap.get(parseInt(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDomainsByOrganization(organizationId: string): Promise<Domain[]> {
|
async getDomainsByCustomer(customerId: string): Promise<Domain[]> {
|
||||||
return Array.from(this.domainsMap.values())
|
return Array.from(this.domainsMap.values())
|
||||||
.filter(domain => domain.organizationId === organizationId);
|
.filter(domain => domain.customerId === customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllDomains(): Promise<Domain[]> {
|
async getAllDomains(): Promise<Domain[]> {
|
||||||
@@ -358,7 +358,7 @@ export class MemStorage implements IStorage {
|
|||||||
const newDomain: Domain = {
|
const newDomain: Domain = {
|
||||||
id: numId.toString(),
|
id: numId.toString(),
|
||||||
name: domain.name,
|
name: domain.name,
|
||||||
organizationId: domain.organizationId!,
|
customerId: domain.customerId,
|
||||||
providerId: domain.providerId || "1", // Default to the first provider if not specified
|
providerId: domain.providerId || "1", // Default to the first provider if not specified
|
||||||
isActive: domain.isActive ?? true,
|
isActive: domain.isActive ?? true,
|
||||||
lastUpdated,
|
lastUpdated,
|
||||||
@@ -502,9 +502,15 @@ export class MemStorage implements IStorage {
|
|||||||
.find(apiToken => apiToken.token === token);
|
.find(apiToken => apiToken.token === token);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApiTokensByOrganization(organizationId: string): Promise<ApiToken[]> {
|
async getApiTokensByCustomer(customerId: string): Promise<ApiToken[]> {
|
||||||
|
// Get all token-customer access records for this customer
|
||||||
|
const customerAccess = Array.from(this.apiTokenCustomerAccessMap.values())
|
||||||
|
.filter(access => access.customerId === customerId);
|
||||||
|
|
||||||
|
// Get the tokens with access to this customer
|
||||||
|
const tokenIds = customerAccess.map(access => access.tokenId);
|
||||||
return Array.from(this.apiTokensMap.values())
|
return Array.from(this.apiTokensMap.values())
|
||||||
.filter(token => token.organizationId === organizationId);
|
.filter(token => tokenIds.includes(token.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
async createApiToken(token: any): Promise<ApiToken> {
|
async createApiToken(token: any): Promise<ApiToken> {
|
||||||
@@ -568,7 +574,7 @@ export class MemStorage implements IStorage {
|
|||||||
id: numId.toString(),
|
id: numId.toString(),
|
||||||
name: token.name || "Unnamed Token",
|
name: token.name || "Unnamed Token",
|
||||||
token: token.token || "test_token_" + numId,
|
token: token.token || "test_token_" + numId,
|
||||||
organizationId: token.organizationId || "1",
|
customerId: token.customerId || "1",
|
||||||
permissions: permissions,
|
permissions: permissions,
|
||||||
role: token.role || 'readonly',
|
role: token.role || 'readonly',
|
||||||
createdBy: token.createdBy || "1",
|
createdBy: token.createdBy || "1",
|
||||||
|
|||||||
Reference in New Issue
Block a user