feat(tokens): Add support for organization-owned API tokens and org-level token management
This commit is contained in:
@@ -15,6 +15,13 @@ export class ApiToken extends plugins.smartdata.SmartDataDbDoc<ApiToken, ApiToke
|
||||
@plugins.smartdata.index()
|
||||
public userId: string = '';
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
@plugins.smartdata.index()
|
||||
public organizationId?: string; // For org-owned tokens
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public createdById?: string; // Who created the token (for audit)
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public name: string = '';
|
||||
|
||||
@@ -90,6 +97,16 @@ export class ApiToken extends plugins.smartdata.SmartDataDbDoc<ApiToken, ApiToke
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tokens for an organization
|
||||
*/
|
||||
public static async getOrgTokens(organizationId: string): Promise<ApiToken[]> {
|
||||
return await ApiToken.getInstances({
|
||||
organizationId,
|
||||
isRevoked: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if token is valid (not expired, not revoked)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user