refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8212)
Follow-up to: https://github.com/n8n-io/n8n/pull/8186
This commit is contained in:
@@ -420,18 +420,13 @@ export async function replaceInvalidCredentials(workflow: WorkflowEntity): Promi
|
||||
* Get the IDs of the workflows that have been shared with the user.
|
||||
* Returns all IDs if user has the 'workflow:read' scope.
|
||||
*/
|
||||
export async function getSharedWorkflowIds(user: User, roles?: RoleNames[]): Promise<string[]> {
|
||||
export async function getSharedWorkflowIds(user: User, roleNames?: RoleNames[]): Promise<string[]> {
|
||||
const where: FindOptionsWhere<SharedWorkflow> = {};
|
||||
if (!user.hasGlobalScope('workflow:read')) {
|
||||
where.userId = user.id;
|
||||
}
|
||||
if (roles?.length) {
|
||||
const roleIds = await Container.get(RoleRepository)
|
||||
.find({
|
||||
select: ['id'],
|
||||
where: { name: In(roles), scope: 'workflow' },
|
||||
})
|
||||
.then((role) => role.map(({ id }) => id));
|
||||
if (roleNames?.length) {
|
||||
const roleIds = await Container.get(RoleRepository).getIdsInScopeWorkflowByNames(roleNames);
|
||||
|
||||
where.roleId = In(roleIds);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user