mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Move more code into @n8n/permissions. Add aditional tests and docs (no-changelog) (#15062)
Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
committed by
GitHub
parent
cdcd059248
commit
2bb190349b
@@ -2,7 +2,7 @@ import type { RoleChangeRequestDto } from '@n8n/api-types';
|
||||
import { User } from '@n8n/db';
|
||||
import type { PublicUser } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { AssignableRole } from '@n8n/permissions';
|
||||
import { getGlobalScopes, type AssignableGlobalRole } from '@n8n/permissions';
|
||||
import { Logger } from 'n8n-core';
|
||||
import type { IUserSettings } from 'n8n-workflow';
|
||||
import { UnexpectedError } from 'n8n-workflow';
|
||||
@@ -71,6 +71,7 @@ export class UserService {
|
||||
let publicUser: PublicUser = {
|
||||
...rest,
|
||||
signInType: ldapIdentity ? 'ldap' : 'email',
|
||||
isOwner: user.role === 'global:owner',
|
||||
};
|
||||
|
||||
if (options?.withInviteUrl && !options?.inviterId) {
|
||||
@@ -85,8 +86,9 @@ export class UserService {
|
||||
publicUser = await this.addFeatureFlags(publicUser, options.posthog);
|
||||
}
|
||||
|
||||
// TODO: resolve these directly in the frontend
|
||||
if (options?.withScopes) {
|
||||
publicUser.globalScopes = user.globalScopes;
|
||||
publicUser.globalScopes = getGlobalScopes(user);
|
||||
}
|
||||
|
||||
return publicUser;
|
||||
@@ -123,7 +125,7 @@ export class UserService {
|
||||
private async sendEmails(
|
||||
owner: User,
|
||||
toInviteUsers: { [key: string]: string },
|
||||
role: AssignableRole,
|
||||
role: AssignableGlobalRole,
|
||||
) {
|
||||
const domain = this.urlService.getInstanceBaseUrl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user