0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

chore: remove org role scopes field since it relies on pagination setup

This commit is contained in:
Darcy Ye 2024-03-20 12:58:12 +08:00
parent 8ac95a1bc2
commit e5e378d1bb
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610
2 changed files with 2 additions and 14 deletions

View file

@ -6,10 +6,6 @@ import { type ScopeLibrary } from '#src/libraries/scope.js';
import { type UserLibrary } from '#src/libraries/user.js'; import { type UserLibrary } from '#src/libraries/user.js';
import type Queries from '#src/tenants/Queries.js'; import type Queries from '#src/tenants/Queries.js';
// Show top 20 organization roles.
const limit = 20;
const offset = 0;
export const createJwtCustomizerLibrary = ( export const createJwtCustomizerLibrary = (
queries: Queries, queries: Queries,
userLibrary: UserLibrary, userLibrary: UserLibrary,
@ -20,7 +16,7 @@ export const createJwtCustomizerLibrary = (
rolesScopes: { findRolesScopesByRoleIds }, rolesScopes: { findRolesScopesByRoleIds },
scopes: { findScopesByIds }, scopes: { findScopesByIds },
userSsoIdentities, userSsoIdentities,
organizations: { relations, roles: organizationRoles }, organizations: { relations },
} = queries; } = queries;
const { findUserRoles } = userLibrary; const { findUserRoles } = userLibrary;
const { attachResourceToScopes } = scopeLibrary; const { attachResourceToScopes } = scopeLibrary;
@ -34,7 +30,6 @@ export const createJwtCustomizerLibrary = (
const scopes = await findScopesByIds(scopeIds); const scopes = await findScopesByIds(scopeIds);
const scopesWithResources = await attachResourceToScopes(scopes); const scopesWithResources = await attachResourceToScopes(scopes);
const organizationsWithRoles = await relations.users.getOrganizationsByUserId(userId); const organizationsWithRoles = await relations.users.getOrganizationsByUserId(userId);
const [_, organizationRolesWithScopes] = await organizationRoles.findAll(limit, offset);
const userContext = { const userContext = {
...pick(user, ...userInfoSelectFields), ...pick(user, ...userInfoSelectFields),
ssoIdentities: fullSsoIdentities.map(pickState('issuer', 'identityId', 'detail')), ssoIdentities: fullSsoIdentities.map(pickState('issuer', 'identityId', 'detail')),
@ -57,7 +52,6 @@ export const createJwtCustomizerLibrary = (
organizationId, organizationId,
roleId, roleId,
roleName, roleName,
scopes: organizationRolesWithScopes.find(({ id }) => id === roleId)?.scopes ?? [],
})) }))
), ),
}; };

View file

@ -1,11 +1,6 @@
import { z } from 'zod'; import { z } from 'zod';
import { import { Organizations, Roles, UserSsoIdentities } from '../db-entries/index.js';
Organizations,
OrganizationScopes,
Roles,
UserSsoIdentities,
} from '../db-entries/index.js';
import { mfaFactorsGuard, jsonObjectGuard } from '../foundations/index.js'; import { mfaFactorsGuard, jsonObjectGuard } from '../foundations/index.js';
import { jwtCustomizerGuard } from './logto-config/index.js'; import { jwtCustomizerGuard } from './logto-config/index.js';
@ -31,7 +26,6 @@ export const jwtCustomizerUserContextGuard = userInfoGuard.extend({
organizationId: z.string(), organizationId: z.string(),
roleId: z.string(), roleId: z.string(),
roleName: z.string(), roleName: z.string(),
scopes: OrganizationScopes.guard.pick({ id: true, name: true }).array(),
}) })
.array(), .array(),
}); });