mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
22 lines
669 B
TypeScript
22 lines
669 B
TypeScript
import { Service } from 'typedi';
|
|
import type { EntityManager, FindOptionsWhere } from 'typeorm';
|
|
import { Role } from '@db/entities/Role';
|
|
import { SharedWorkflowRepository } from '@db/repositories';
|
|
|
|
@Service()
|
|
export class RoleService {
|
|
constructor(private sharedWorkflowRepository: SharedWorkflowRepository) {}
|
|
|
|
static async trxGet(transaction: EntityManager, role: FindOptionsWhere<Role>) {
|
|
return transaction.findOneBy(Role, role);
|
|
}
|
|
|
|
async getUserRoleForWorkflow(userId: string, workflowId: string) {
|
|
const shared = await this.sharedWorkflowRepository.findOne({
|
|
where: { workflowId, userId },
|
|
relations: ['role'],
|
|
});
|
|
return shared?.role;
|
|
}
|
|
}
|