mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-04 14:57:20 +02:00
fix: rename createRole/deleteRole to avoid AccessRole name collision
The existing accessRole.ts already exports createRole/deleteRole for the AccessRole model. In createMethods index.ts, these are spread after roleMethods, overwriting them. Renamed our Role methods to createRoleByName/deleteRoleByName to match the existing pattern (getRoleByName, updateRoleByName) and avoid the collision.
This commit is contained in:
parent
69093a5d99
commit
f947546fea
3 changed files with 12 additions and 12 deletions
|
|
@ -343,7 +343,7 @@ export function createRoleMethods(mongoose: typeof import('mongoose'), deps: Rol
|
|||
}
|
||||
|
||||
/** Rejects names that match system roles. */
|
||||
async function createRole(roleData: Partial<IRole>): Promise<IRole> {
|
||||
async function createRoleByName(roleData: Partial<IRole>): Promise<IRole> {
|
||||
const { name } = roleData;
|
||||
if (!name || typeof name !== 'string' || !name.trim()) {
|
||||
throw new Error('Role name is required');
|
||||
|
|
@ -368,7 +368,7 @@ export function createRoleMethods(mongoose: typeof import('mongoose'), deps: Rol
|
|||
}
|
||||
|
||||
/** Guards against deleting system roles. Reassigns affected users back to USER. */
|
||||
async function deleteRole(roleName: string): Promise<IRole | null> {
|
||||
async function deleteRoleByName(roleName: string): Promise<IRole | null> {
|
||||
if (SystemRoles[roleName as keyof typeof SystemRoles]) {
|
||||
throw new Error(`Cannot delete system role: ${roleName}`);
|
||||
}
|
||||
|
|
@ -399,8 +399,8 @@ export function createRoleMethods(mongoose: typeof import('mongoose'), deps: Rol
|
|||
updateRoleByName,
|
||||
updateAccessPermissions,
|
||||
migrateRoleSchema,
|
||||
createRole,
|
||||
deleteRole,
|
||||
createRoleByName,
|
||||
deleteRoleByName,
|
||||
listUsersByRole,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue