From e5e378d1bb9d634e2f49e96d7b4aa0ebb78f4e4f Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Wed, 20 Mar 2024 12:58:12 +0800 Subject: [PATCH] chore: remove org role scopes field since it relies on pagination setup --- packages/core/src/libraries/jwt-customizer.ts | 8 +------- packages/schemas/src/types/jwt-customizer.ts | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/core/src/libraries/jwt-customizer.ts b/packages/core/src/libraries/jwt-customizer.ts index 36f437145..34f13c6f1 100644 --- a/packages/core/src/libraries/jwt-customizer.ts +++ b/packages/core/src/libraries/jwt-customizer.ts @@ -6,10 +6,6 @@ import { type ScopeLibrary } from '#src/libraries/scope.js'; import { type UserLibrary } from '#src/libraries/user.js'; import type Queries from '#src/tenants/Queries.js'; -// Show top 20 organization roles. -const limit = 20; -const offset = 0; - export const createJwtCustomizerLibrary = ( queries: Queries, userLibrary: UserLibrary, @@ -20,7 +16,7 @@ export const createJwtCustomizerLibrary = ( rolesScopes: { findRolesScopesByRoleIds }, scopes: { findScopesByIds }, userSsoIdentities, - organizations: { relations, roles: organizationRoles }, + organizations: { relations }, } = queries; const { findUserRoles } = userLibrary; const { attachResourceToScopes } = scopeLibrary; @@ -34,7 +30,6 @@ export const createJwtCustomizerLibrary = ( const scopes = await findScopesByIds(scopeIds); const scopesWithResources = await attachResourceToScopes(scopes); const organizationsWithRoles = await relations.users.getOrganizationsByUserId(userId); - const [_, organizationRolesWithScopes] = await organizationRoles.findAll(limit, offset); const userContext = { ...pick(user, ...userInfoSelectFields), ssoIdentities: fullSsoIdentities.map(pickState('issuer', 'identityId', 'detail')), @@ -57,7 +52,6 @@ export const createJwtCustomizerLibrary = ( organizationId, roleId, roleName, - scopes: organizationRolesWithScopes.find(({ id }) => id === roleId)?.scopes ?? [], })) ), }; diff --git a/packages/schemas/src/types/jwt-customizer.ts b/packages/schemas/src/types/jwt-customizer.ts index 8ec51b1d3..22a21a712 100644 --- a/packages/schemas/src/types/jwt-customizer.ts +++ b/packages/schemas/src/types/jwt-customizer.ts @@ -1,11 +1,6 @@ import { z } from 'zod'; -import { - Organizations, - OrganizationScopes, - Roles, - UserSsoIdentities, -} from '../db-entries/index.js'; +import { Organizations, Roles, UserSsoIdentities } from '../db-entries/index.js'; import { mfaFactorsGuard, jsonObjectGuard } from '../foundations/index.js'; import { jwtCustomizerGuard } from './logto-config/index.js'; @@ -31,7 +26,6 @@ export const jwtCustomizerUserContextGuard = userInfoGuard.extend({ organizationId: z.string(), roleId: z.string(), roleName: z.string(), - scopes: OrganizationScopes.guard.pick({ id: true, name: true }).array(), }) .array(), });