Class BaseUserManager<U, UR, O, ST>

User manager helps to resolve user in auth-n decorators Provide current user with permissions for each request context

Type Parameters

Constructors

Properties

appConfig: AppConfigType
cacheManager: Cache
commonAuthorizedUsersPermissions: string[]
commonUsersPermissions: string[]
dataSource: DataSource
loggerFactory: WinstonLoggerFactory
permissionGroups: PermissionGroup[]
userDataLoader: DataLoader<string, U>

Accessors

  • get organizationRepository(): Repository<O>

    Returns Repository<O>

  • get serviceTokenRepository(): Repository<ST>

    Returns Repository<ST>

  • get userRepository(): Repository<U>

    Returns Repository<U>

  • get userToRoleRepository(): Repository<UR>

    Returns Repository<UR>

Methods

  • Allows your application to create a special context for cases where it needs to perform tasks internally without an external user request.

    This method generates a BaseServiceMethodContext with a app service account user, which can be used to call other services within the application.

    Returns Promise<BaseServiceMethodContext>

    • app service account context
  • Extract permissions from permission groups

    Parameters

    • idsWithScopes: string[]

      permission group ids with scopes (like g:bo:core:brands[org]:edit)

    Returns ResolvedPermission[]

    • resolved permissions
  • Returns void

  • Find user by id and resolve permissions

    Parameters

    • userId: string

      user id

    Returns Promise<U>

    • user with resolved permissions
  • Returns guest user with resolved permissions Used in auth-n decorators when user is not authorized

    Returns U

    • guest user with resolved permissions
  • Resolves test user. This method must be implemented by child project.

    Parameters

    Returns Promise<U>

    The resolved test user.

  • Resolve user permissions. Extracts permissions from user roles and merges them with common permissions and custom user permissions Resolves named scopes and replace it by ids

    Parameters

    • user: U

      user entity

    Returns Promise<ReadonlyResolvedPermission[]>

    • resolved permissions
  • Parameters

    • userId: string

    Returns Promise<U>