@acorex-platform/module-security-management-client 0.0.37 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/{acorex-platform-module-security-management-client-acorex-platform-module-security-management-client-Ddzg9VYV.mjs → acorex-platform-module-security-management-client-acorex-platform-module-security-management-client-D-VISihP.mjs} +116 -37
- package/fesm2022/acorex-platform-module-security-management-client-acorex-platform-module-security-management-client-D-VISihP.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-cancel-invitation.command-C3iaOEKI.mjs +74 -0
- package/fesm2022/acorex-platform-module-security-management-client-cancel-invitation.command-C3iaOEKI.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-device-sessions.mjs +22 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-device-sessions.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-identity-provider.mjs +232 -16
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-identity-provider.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-policy.mjs +21 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-policy.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-profile.mjs +21 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-profile.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-role-permission.mjs +22 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-role-permission.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-roles.mjs +22 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-roles.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-user-role.mjs +22 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-user-role.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-user-two-factor.mjs +182 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-user-two-factor.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-users.mjs +165 -3
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entities-users.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-acorex-platform-module-security-management-client-contracts-entity-catalog-CeqvAe30.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-acorex-platform-module-security-management-client-contracts-entity-catalog-B4oiF8FO.mjs} +16 -9
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-acorex-platform-module-security-management-client-contracts-entity-catalog-B4oiF8FO.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-device-sessions.entity-D5wMKRJ3.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-device-sessions.entity-CU-5X-qu.mjs} +18 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-device-sessions.entity-CU-5X-qu.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-identity-provider.entity-6LBD6MuU.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-identity-provider.entity-Bld1buTd.mjs} +228 -18
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-identity-provider.entity-Bld1buTd.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-policy.entity-CVsH_anF.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-policy.entity-DZVzHzVM.mjs} +17 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-policy.entity-DZVzHzVM.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-profile.entity-B3m3wpcT.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-profile.entity-BCy5fNc9.mjs} +17 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-profile.entity-BCy5fNc9.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-role-permission.entity-DK99ir3U.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-role-permission.entity-DcvYjfZm.mjs} +18 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-role-permission.entity-DcvYjfZm.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-roles.entity-B5PknTEu.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-roles.entity-lNKDIDry.mjs} +18 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-roles.entity-lNKDIDry.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-user-role.entity-IHUWsgjf.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-user-role.entity-DKII6o5N.mjs} +18 -2
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-user-role.entity-DKII6o5N.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-user-two-factor.entity-ge21b3mE.mjs +100 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-user-two-factor.entity-ge21b3mE.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-security-management-client-contracts-entity-catalog-users.entity-DmVp5gj1.mjs → acorex-platform-module-security-management-client-contracts-entity-catalog-users.entity-CJ7x5rjC.mjs} +161 -5
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-users.entity-CJ7x5rjC.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog.mjs +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts.mjs +187 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-security-management-client-index-C1rCxs2K.mjs → acorex-platform-module-security-management-client-index-CT-N83bV.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-security-management-client-index-C1rCxs2K.mjs.map → acorex-platform-module-security-management-client-index-CT-N83bV.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-invitation-target.util-BAXQZwLW.mjs +41 -0
- package/fesm2022/acorex-platform-module-security-management-client-invitation-target.util-BAXQZwLW.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-invite-user.command-kFXjLdxy.mjs +143 -0
- package/fesm2022/acorex-platform-module-security-management-client-invite-user.command-kFXjLdxy.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-local-entities.mjs +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-local-entities.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-security-management-client-resend-invitation.command-D9Ijk565.mjs +76 -0
- package/fesm2022/acorex-platform-module-security-management-client-resend-invitation.command-D9Ijk565.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client-reset-two-factor.command-psTDKoNf.mjs +96 -0
- package/fesm2022/acorex-platform-module-security-management-client-reset-two-factor.command-psTDKoNf.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-security-management-client.mjs +1 -1
- package/package.json +5 -1
- package/types/acorex-platform-module-security-management-client-contracts-entities-user-two-factor.d.ts +9 -0
- package/types/acorex-platform-module-security-management-client-contracts.d.ts +264 -10
- package/fesm2022/acorex-platform-module-security-management-client-acorex-platform-module-security-management-client-Ddzg9VYV.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-acorex-platform-module-security-management-client-contracts-entity-catalog-CeqvAe30.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-device-sessions.entity-D5wMKRJ3.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-identity-provider.entity-6LBD6MuU.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-policy.entity-CVsH_anF.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-profile.entity-B3m3wpcT.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-role-permission.entity-DK99ir3U.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-roles.entity-B5PknTEu.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-user-role.entity-IHUWsgjf.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-security-management-client-contracts-entity-catalog-users.entity-DmVp5gj1.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acorex-platform-module-security-management-client-index-C1rCxs2K.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/features/user-roles/user-role-grant.service.ts","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page.component.ts","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page.component.html","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page-component.provider.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport { AXPEntityBroadcastService } from '@acorex-platform/framework-client/core';\nimport {\n AXPEntityDefinitionRegistryService,\n AXPEntityService,\n dispatchEntityModifiedSideEffects,\n} from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-security-management-client/contracts';\nimport { Injectable, inject } from '@angular/core';\nimport type {\n SaveUserRoleGrantOptions,\n UserRoleGrantRow,\n UserRoleOption,\n} from './user-role-grant.types';\n\n//#endregion\n\n//#region ----- Service -----\n\n/**\n * Loads and persists scoped UserRole assignments for a user.\n * Shared by the User roles detail page.\n */\n@Injectable({ providedIn: 'root' })\nexport class AXMUserRoleGrantService {\n //#region ----- Services & Dependencies -----\n\n private readonly entityRegistry = inject(AXPEntityDefinitionRegistryService);\n private readonly entityService = inject(AXPEntityService);\n private readonly sessionService = inject(AXPSessionService);\n private readonly entityEvents = inject(AXPEntityBroadcastService);\n\n //#endregion\n\n //#region ----- Scope -----\n\n resolveSessionScope(): { tenantId: string; applicationId: string | undefined } | null {\n const tenantId = this.sessionService.tenant?.id;\n if (!tenantId) {\n return null;\n }\n return {\n tenantId,\n applicationId: this.sessionService.application?.id,\n };\n }\n\n //#endregion\n\n //#region ----- Query -----\n\n private userRoleData() {\n return this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.userRole.name)\n .data<string, UserRoleGrantRow, UserRoleGrantRow>();\n }\n\n /**\n * Roles available to assign in the current workspace.\n * Also loads any already-assigned role ids that list queries hide (`stateInfo.isHidden`).\n */\n async listRoleOptions(includeRoleIds: readonly string[] = []): Promise<UserRoleOption[]> {\n const roleData = this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.roles.name)\n .data<string, UserRoleOption, UserRoleOption>();\n\n const result = await roleData.query({\n skip: 0,\n take: 500,\n } as never);\n\n const byId = new Map<string, UserRoleOption>();\n const items = (result?.items ?? []) as unknown as Array<Record<string, unknown>>;\n for (const item of items) {\n const id = String(item['id'] ?? '');\n if (!id) {\n continue;\n }\n byId.set(id, {\n id,\n title: String(item['title'] ?? item['name'] ?? ''),\n name: typeof item['name'] === 'string' ? item['name'] : undefined,\n });\n }\n\n const missingIds = includeRoleIds.filter((id) => id && !byId.has(id));\n await Promise.all(\n missingIds.map(async (id) => {\n try {\n const row = (await roleData.byKey(id)) as Record<string, unknown> | null;\n if (!row?.['id']) {\n return;\n }\n byId.set(String(row['id']), {\n id: String(row['id']),\n title: String(row['title'] ?? row['name'] ?? row['id']),\n name: typeof row['name'] === 'string' ? row['name'] : undefined,\n });\n } catch {\n /* role missing or inaccessible */\n }\n }),\n );\n\n return [...byId.values()].sort((a, b) => a.title.localeCompare(b.title));\n }\n\n async findGrant(\n userId: string,\n tenantId: string,\n applicationId: string | undefined,\n ): Promise<UserRoleGrantRow | null> {\n const result = await this.userRoleData().query({\n skip: 0,\n take: 50,\n filter: {\n logic: 'and',\n filters: [\n { field: 'userId', operator: { type: 'equal' }, value: userId },\n { field: 'scopeInfo.tenantId', operator: { type: 'equal' }, value: tenantId },\n ],\n },\n } as never);\n\n const items = (result?.items ?? []) as UserRoleGrantRow[];\n if (items.length === 0) {\n return null;\n }\n\n if (applicationId) {\n const appMatch = items.find((item) => item.scopeInfo?.applicationId === applicationId);\n if (appMatch) {\n return appMatch;\n }\n }\n\n const tenantWide = items.find((item) => !item.scopeInfo?.applicationId);\n return tenantWide ?? items[0] ?? null;\n }\n\n //#endregion\n\n //#region ----- Persist -----\n\n async saveGrant(options: SaveUserRoleGrantOptions): Promise<Record<string, unknown>> {\n const existingState = options.existing?.stateInfo;\n if (existingState?.isSystem === true || existingState?.isImmutable === true) {\n throw new Error('System user role grants are readonly.');\n }\n\n const entityKey = `${RootConfig.module.name}.${RootConfig.entities.userRole.name}`;\n const [moduleName, entityName] = entityKey.split('.');\n const entityRef = await this.entityRegistry.resolve(moduleName, entityName);\n\n const scopeInfo = {\n tenantId: options.tenantId,\n ...(options.existing?.scopeInfo?.applicationId\n ? { applicationId: options.existing.scopeInfo.applicationId }\n : options.applicationId\n ? { applicationId: options.applicationId }\n : {}),\n };\n\n if (options.existing?.id) {\n const updatePayload = {\n ...options.existing,\n userId: options.userId,\n roleIds: options.roleIds,\n scopeInfo,\n };\n return (\n entityRef.commands?.update?.execute as (data: Record<string, unknown>) => Promise<Record<string, unknown>>\n )(updatePayload);\n }\n\n const createPayload = {\n userId: options.userId,\n roleIds: options.roleIds,\n scopeInfo,\n };\n return (\n entityRef.commands?.create?.execute as (data: Record<string, unknown>) => Promise<Record<string, unknown>>\n )(createPayload);\n }\n\n notifyGrantModified(saved: Record<string, unknown>): void {\n const entityKey = `${RootConfig.module.name}.${RootConfig.entities.userRole.name}`;\n dispatchEntityModifiedSideEffects(this.entityEvents, entityKey, saved);\n }\n\n //#endregion\n}\n\n//#endregion\n","//#region ----- Imports -----\n\nimport {\n AXPActionMenuItem,\n AXPExecuteCommand,\n type AXPRuntimeCommandResult,\n} from '@acorex-platform/framework-shared/core';\nimport type { AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport type { AXPLayoutDetailsViewAction } from '@acorex-platform/framework-client/layout/views';\nimport { AXPPageLayoutBase, AXPPageLayoutBaseComponent } from '@acorex-platform/framework-client/layout/views';\nimport { AXPStateMessageComponent } from '@acorex-platform/framework-client/layout/components';\nimport { AXValueChangedEvent } from '@acorex/cdk/common';\nimport { AXSelectionListModule } from '@acorex/components/selection-list';\nimport { AXSkeletonModule } from '@acorex/components/skeleton';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { AsyncPipe } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { isEqual } from 'lodash-es';\nimport { resolvePersistedEntityId } from '../../../permissions/resolve-persisted-entity-id.util';\nimport { AXMUserRoleGrantService } from '../../user-role-grant.service';\nimport type { UserRoleGrantRow, UserRoleOption } from '../../user-role-grant.types';\n\n//#endregion\n\n//#region ----- Constants -----\n\nconst USER_ROLES_DISCARD_COMMAND = 'User:Roles:Discard';\nconst USER_ROLES_SAVE_COMMAND = 'User:Roles:Save';\n\n//#endregion\n\n//#region ----- Component -----\n\n/**\n * User detail/create wizard page that edits scoped UserRole assignments.\n */\n@Component({\n selector: 'axm-user-roles-page',\n standalone: true,\n imports: [\n AXPStateMessageComponent,\n AXSelectionListModule,\n AXSkeletonModule,\n AXTranslationModule,\n AsyncPipe,\n FormsModule,\n ],\n templateUrl: './user-roles-page.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: AXPPageLayoutBase,\n useExisting: AXMUserRolesPageComponent,\n },\n ],\n host: {\n class: 'flex h-full min-h-0 flex-1 flex-col overflow-hidden',\n },\n})\nexport class AXMUserRolesPageComponent extends AXPPageLayoutBaseComponent {\n //#region ----- Inputs -----\n\n rootContext = input<Record<string, unknown>>();\n pageConfig = input<Record<string, unknown>>();\n\n //#endregion\n\n //#region ----- Services & Dependencies -----\n\n private readonly grantService = inject(AXMUserRoleGrantService);\n private readonly hostPageLayout = inject(AXPPageLayoutBase, { optional: true, skipSelf: true });\n\n //#endregion\n\n //#region ----- State Signals -----\n\n private readonly loadedUserId = signal<string | undefined>(undefined);\n private readonly existingGrant = signal<UserRoleGrantRow | null>(null);\n private readonly baselineRoleIds = signal<string[]>([]);\n protected readonly currentRoleIds = signal<string[]>([]);\n protected readonly roleOptions = signal<UserRoleOption[]>([]);\n protected readonly isLoading = signal(true);\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly userId = computed(() => resolvePersistedEntityId(this.rootContext()));\n\n protected readonly isDirty = computed(() => {\n return !this.areRoleSetsEqual(this.baselineRoleIds(), this.currentRoleIds());\n });\n\n /** System UserRole grants are seeded and not editable in product/platform UI. */\n protected readonly isGrantReadonly = computed(() => {\n const state = this.existingGrant()?.stateInfo;\n return state?.isSystem === true || state?.isImmutable === true;\n });\n\n /** Checkbox + label row placeholders for the loading skeleton */\n protected readonly roleSkeletonPlaceholders = computed(() => [\n 'w-40',\n 'w-28',\n 'w-48',\n 'w-32',\n 'w-44',\n 'w-36',\n 'w-40',\n 'w-52',\n ]);\n\n //#endregion\n\n //#region ----- Lifecycle -----\n\n constructor() {\n super();\n effect(() => {\n const id = this.userId();\n untracked(() => {\n void this.loadGrantForUser(id);\n });\n });\n }\n\n //#endregion\n\n //#region ----- Unsaved Changes -----\n\n override hasUnsavedChanges(): boolean {\n return this.isDirty();\n }\n\n //#endregion\n\n //#region ----- Page Actions -----\n\n override async getPrimaryMenuItems(): Promise<AXPActionMenuItem[]> {\n const discardTitle = (await this.translateService.translateAsync('@general:actions.discard.title')) || 'Discard';\n const saveTitle = (await this.translateService.translateAsync('@general:actions.save.title')) || 'Save';\n const canEdit = !!this.userId() && !this.isLoading() && !this.isGrantReadonly();\n\n const discardAction: AXPLayoutDetailsViewAction = {\n title: discardTitle,\n icon: 'fa-light fa-rotate-left',\n zone: 'footer',\n priority: 'secondary',\n color: 'default',\n visible: canEdit && this.isDirty(),\n command: { name: USER_ROLES_DISCARD_COMMAND, options: {} },\n };\n\n const saveAction: AXPLayoutDetailsViewAction = {\n title: saveTitle,\n icon: 'fa-light fa-floppy-disk',\n zone: 'footer',\n priority: 'primary',\n color: 'primary',\n visible: canEdit && this.isDirty(),\n command: { name: USER_ROLES_SAVE_COMMAND, options: {} },\n };\n\n return [discardAction, saveAction];\n }\n\n //#endregion\n\n //#region ----- Command Handling -----\n\n override execute(command: AXPExecuteCommand): void | Promise<void> {\n if (command.name === USER_ROLES_DISCARD_COMMAND) {\n this.handleDiscard();\n return;\n }\n if (command.name !== USER_ROLES_SAVE_COMMAND) {\n return;\n }\n return this.handleSaveExecute() as unknown as Promise<void>;\n }\n\n private async handleSaveExecute(): AXPCommandExecuteResultPromise {\n const userId = this.userId();\n const scope = this.grantService.resolveSessionScope();\n\n if (!userId || !scope) {\n return {\n success: false,\n message: {\n text: await this.translateService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n try {\n const roleIds = [...this.currentRoleIds()];\n const saved = await this.grantService.saveGrant({\n existing: this.existingGrant(),\n userId,\n roleIds,\n tenantId: scope.tenantId,\n applicationId: scope.applicationId,\n });\n\n const nextGrant: UserRoleGrantRow = {\n id: String(saved['id'] ?? this.existingGrant()?.id ?? ''),\n userId,\n roleIds,\n scopeInfo: (saved['scopeInfo'] as UserRoleGrantRow['scopeInfo']) ?? this.existingGrant()?.scopeInfo,\n };\n this.existingGrant.set(nextGrant.id ? nextGrant : this.existingGrant());\n this.baselineRoleIds.set([...roleIds]);\n this.currentRoleIds.set([...roleIds]);\n this.grantService.notifyGrantModified(saved);\n this.recompute();\n\n return {\n success: true,\n kind: 'object',\n data: roleIds,\n } as AXPRuntimeCommandResult;\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Failed to save roles.';\n return {\n success: false,\n message: { text: message },\n };\n }\n }\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected onRolesValueChanged(event: AXValueChangedEvent): void {\n if (!event.isUserInteraction || this.isGrantReadonly()) {\n return;\n }\n\n const next = Array.isArray(event.value)\n ? event.value.map(String)\n : event.value != null\n ? [String(event.value)]\n : [];\n\n this.currentRoleIds.set(next);\n this.recompute();\n }\n\n private handleDiscard(): void {\n this.currentRoleIds.set([...this.baselineRoleIds()]);\n this.recompute();\n }\n\n //#endregion\n\n //#region ----- Wizard step context -----\n\n override getWizardStepContext(): Record<string, unknown> | null {\n return null;\n }\n\n //#endregion\n\n //#region ----- Data Loading -----\n\n private async loadGrantForUser(userId: string | undefined): Promise<void> {\n if (!userId) {\n this.loadedUserId.set(undefined);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.roleOptions.set([]);\n this.isLoading.set(false);\n this.recompute();\n return;\n }\n\n if (userId === this.loadedUserId() && !this.isLoading()) {\n return;\n }\n\n this.isLoading.set(true);\n this.recompute();\n\n const scope = this.grantService.resolveSessionScope();\n if (!scope) {\n this.loadedUserId.set(userId);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.isLoading.set(false);\n this.recompute();\n return;\n }\n\n try {\n const grant = await this.grantService.findGrant(userId, scope.tenantId, scope.applicationId);\n const roleIds = [...(grant?.roleIds ?? [])];\n const options = await this.grantService.listRoleOptions(roleIds);\n this.loadedUserId.set(userId);\n this.existingGrant.set(grant);\n this.baselineRoleIds.set(roleIds);\n this.currentRoleIds.set([...roleIds]);\n this.roleOptions.set(options);\n } catch {\n this.loadedUserId.set(userId);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.roleOptions.set([]);\n } finally {\n this.isLoading.set(false);\n this.recompute();\n }\n }\n\n //#endregion\n\n //#region ----- Utility Methods -----\n\n private areRoleSetsEqual(a: string[], b: string[]): boolean {\n return isEqual([...a].sort(), [...b].sort());\n }\n\n protected override recompute(): void {\n super.recompute();\n const maybeLayout = this.hostPageLayout as unknown as { recompute?: () => void };\n maybeLayout?.recompute?.();\n }\n\n //#endregion\n}\n\n//#endregion\n","@if (isLoading()) {\n <!-- ----- Skeleton while UserRole grant loads for the current workspace ----- -->\n <div class=\"flex h-full min-h-0 flex-1 flex-col overflow-auto p-4\" aria-hidden=\"true\">\n <div class=\"user-roles-frame rounded border border-default bg-lightest p-4\">\n <div class=\"mb-4 h-4 w-3/5 max-w-md rounded-md overflow-hidden\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n <div class=\"flex flex-col gap-3\">\n @for (widthClass of roleSkeletonPlaceholders(); track $index) {\n <!-- ----- One checkbox + label row placeholder ----- -->\n <div class=\"flex items-center gap-3\">\n <div class=\"h-4 w-4 shrink-0 rounded-sm overflow-hidden\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n <div class=\"h-4 max-w-full rounded-md overflow-hidden\" [class]=\"widthClass\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n </div>\n }\n </div>\n </div>\n </div>\n}\n<!-- ----- User must be persisted before role grants can be edited ----- -->\n@else if (!userId()) {\n <div class=\"flex h-full min-h-[20rem] items-center justify-center p-6\">\n <axp-state-message\n [title]=\"'@security-management:users.entities.user.pages.roles.save-user-first.title'\"\n [description]=\"'@security-management:users.entities.user.pages.roles.save-user-first.description'\"\n ></axp-state-message>\n </div>\n}\n<!-- ----- Scoped role checklist for the current tenant/application ----- -->\n@else {\n <div class=\"flex h-full min-h-0 flex-1 flex-col overflow-auto p-4\">\n <div class=\"user-roles-frame rounded border border-default bg-lightest p-4\">\n <p class=\"mb-4 text-sm opacity-70\">\n {{ '@security-management:users.entities.user.pages.roles.description' | translate | async }}\n </p>\n <ax-selection-list\n class=\"w-full\"\n valueField=\"id\"\n textField=\"title\"\n look=\"solid\"\n direction=\"vertical\"\n [multiple]=\"true\"\n [showControl]=\"true\"\n [items]=\"roleOptions()\"\n [ngModel]=\"currentRoleIds()\"\n [disabled]=\"isGrantReadonly()\"\n [readonly]=\"isGrantReadonly()\"\n (onValueChanged)=\"onRolesValueChanged($event)\"\n ></ax-selection-list>\n </div>\n </div>\n}\n","//#region ----- Imports -----\n\nimport {\n AXPPageComponentDefinition,\n AXPPageComponentProvider,\n} from '@acorex-platform/framework-client/layout/components';\nimport { USER_ROLES_PAGE_COMPONENT_KEY } from '@acorex-platform/module-security-management-client/contracts';\nimport { Injectable } from '@angular/core';\n\n//#endregion\n\n//#region ----- Provider -----\n\n@Injectable()\nexport class AXMUserRolesPageComponentProvider implements AXPPageComponentProvider {\n async components(): Promise<AXPPageComponentDefinition[]> {\n return [\n {\n key: USER_ROLES_PAGE_COMPONENT_KEY,\n loader: () =>\n import('./user-roles-page.component').then((m) => m.AXMUserRolesPageComponent),\n },\n ];\n }\n}\n\n//#endregion\n"],"names":["i2","i3","i4"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAiBA;AAEA;AAEA;;;AAGG;MAEU,uBAAuB,CAAA;AADpC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,kCAAkC,CAAC;AAC3D,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,yBAAyB,CAAC;AAiKlE,IAAA;;;IA3JC,mBAAmB,GAAA;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE;QAC/C,IAAI,CAAC,QAAQ,EAAE;AACb,YAA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uB,CAAC,MAAM,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAA,yBAA2B;AACvC,yBAAA;qBACF,EAAA,IAAA,EACK;AACJ,wBAAA,KAAK,EAAE,qDAAqD;AAC7D,qBAAA,EAAA,QAAA,EAAA,gpFAAA,EAAA;;;;;;;;AE1DH;AAEA;MAGa,iCAAiC,CAAA;AAC5C,IAAA,MAAM,UAAU,GAAA;QACd,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,6BAA6B;AAClC,gBAAA,MAAM,EAAE,MACN,uEAAqC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,yBAAyB,CAAC;AACjF,aAAA;SACF;IACH;8GATW,iCAAiC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAjC,iCAAiC,EAAA,CAAA,CAAA;;2FAAjC,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAD7C;;;"}
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-security-management-client-index-CT-N83bV.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/features/user-roles/user-role-grant.service.ts","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page.component.ts","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page.component.html","../../../../libs/modules/security-management/client/src/lib/features/user-roles/pages/user-roles-page/user-roles-page-component.provider.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport { AXPEntityBroadcastService } from '@acorex-platform/framework-client/core';\nimport {\n AXPEntityDefinitionRegistryService,\n AXPEntityService,\n dispatchEntityModifiedSideEffects,\n} from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-security-management-client/contracts';\nimport { Injectable, inject } from '@angular/core';\nimport type {\n SaveUserRoleGrantOptions,\n UserRoleGrantRow,\n UserRoleOption,\n} from './user-role-grant.types';\n\n//#endregion\n\n//#region ----- Service -----\n\n/**\n * Loads and persists scoped UserRole assignments for a user.\n * Shared by the User roles detail page.\n */\n@Injectable({ providedIn: 'root' })\nexport class AXMUserRoleGrantService {\n //#region ----- Services & Dependencies -----\n\n private readonly entityRegistry = inject(AXPEntityDefinitionRegistryService);\n private readonly entityService = inject(AXPEntityService);\n private readonly sessionService = inject(AXPSessionService);\n private readonly entityEvents = inject(AXPEntityBroadcastService);\n\n //#endregion\n\n //#region ----- Scope -----\n\n resolveSessionScope(): { tenantId: string; applicationId: string | undefined } | null {\n const tenantId = this.sessionService.tenant?.id;\n if (!tenantId) {\n return null;\n }\n return {\n tenantId,\n applicationId: this.sessionService.application?.id,\n };\n }\n\n //#endregion\n\n //#region ----- Query -----\n\n private userRoleData() {\n return this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.userRole.name)\n .data<string, UserRoleGrantRow, UserRoleGrantRow>();\n }\n\n /**\n * Roles available to assign in the current workspace.\n * Also loads any already-assigned role ids that list queries hide (`stateInfo.isHidden`).\n */\n async listRoleOptions(includeRoleIds: readonly string[] = []): Promise<UserRoleOption[]> {\n const roleData = this.entityService\n .withEntity(RootConfig.module.name, RootConfig.entities.roles.name)\n .data<string, UserRoleOption, UserRoleOption>();\n\n const result = await roleData.query({\n skip: 0,\n take: 500,\n } as never);\n\n const byId = new Map<string, UserRoleOption>();\n const items = (result?.items ?? []) as unknown as Array<Record<string, unknown>>;\n for (const item of items) {\n const id = String(item['id'] ?? '');\n if (!id) {\n continue;\n }\n byId.set(id, {\n id,\n title: String(item['title'] ?? item['name'] ?? ''),\n name: typeof item['name'] === 'string' ? item['name'] : undefined,\n });\n }\n\n const missingIds = includeRoleIds.filter((id) => id && !byId.has(id));\n await Promise.all(\n missingIds.map(async (id) => {\n try {\n const row = (await roleData.byKey(id)) as Record<string, unknown> | null;\n if (!row?.['id']) {\n return;\n }\n byId.set(String(row['id']), {\n id: String(row['id']),\n title: String(row['title'] ?? row['name'] ?? row['id']),\n name: typeof row['name'] === 'string' ? row['name'] : undefined,\n });\n } catch {\n /* role missing or inaccessible */\n }\n }),\n );\n\n return [...byId.values()].sort((a, b) => a.title.localeCompare(b.title));\n }\n\n async findGrant(\n userId: string,\n tenantId: string,\n applicationId: string | undefined,\n ): Promise<UserRoleGrantRow | null> {\n const result = await this.userRoleData().query({\n skip: 0,\n take: 50,\n filter: {\n logic: 'and',\n filters: [\n { field: 'userId', operator: { type: 'equal' }, value: userId },\n { field: 'scopeInfo.tenantId', operator: { type: 'equal' }, value: tenantId },\n ],\n },\n } as never);\n\n const items = (result?.items ?? []) as UserRoleGrantRow[];\n if (items.length === 0) {\n return null;\n }\n\n if (applicationId) {\n const appMatch = items.find((item) => item.scopeInfo?.applicationId === applicationId);\n if (appMatch) {\n return appMatch;\n }\n }\n\n const tenantWide = items.find((item) => !item.scopeInfo?.applicationId);\n return tenantWide ?? items[0] ?? null;\n }\n\n //#endregion\n\n //#region ----- Persist -----\n\n async saveGrant(options: SaveUserRoleGrantOptions): Promise<Record<string, unknown>> {\n const existingState = options.existing?.stateInfo;\n if (existingState?.isSystem === true || existingState?.isImmutable === true) {\n throw new Error('System user role grants are readonly.');\n }\n\n const entityKey = `${RootConfig.module.name}.${RootConfig.entities.userRole.name}`;\n const [moduleName, entityName] = entityKey.split('.');\n const entityRef = await this.entityRegistry.resolve(moduleName, entityName);\n\n const scopeInfo = {\n tenantId: options.tenantId,\n ...(options.existing?.scopeInfo?.applicationId\n ? { applicationId: options.existing.scopeInfo.applicationId }\n : options.applicationId\n ? { applicationId: options.applicationId }\n : {}),\n };\n\n if (options.existing?.id) {\n const updatePayload = {\n ...options.existing,\n userId: options.userId,\n roleIds: options.roleIds,\n scopeInfo,\n };\n return (\n entityRef.commands?.update?.execute as (data: Record<string, unknown>) => Promise<Record<string, unknown>>\n )(updatePayload);\n }\n\n const createPayload = {\n userId: options.userId,\n roleIds: options.roleIds,\n scopeInfo,\n };\n return (\n entityRef.commands?.create?.execute as (data: Record<string, unknown>) => Promise<Record<string, unknown>>\n )(createPayload);\n }\n\n notifyGrantModified(saved: Record<string, unknown>): void {\n const entityKey = `${RootConfig.module.name}.${RootConfig.entities.userRole.name}`;\n dispatchEntityModifiedSideEffects(this.entityEvents, entityKey, saved);\n }\n\n //#endregion\n}\n\n//#endregion\n","//#region ----- Imports -----\n\nimport {\n AXPActionMenuItem,\n AXPExecuteCommand,\n type AXPRuntimeCommandResult,\n} from '@acorex-platform/framework-shared/core';\nimport type { AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport type { AXPLayoutDetailsViewAction } from '@acorex-platform/framework-client/layout/views';\nimport { AXPPageLayoutBase, AXPPageLayoutBaseComponent } from '@acorex-platform/framework-client/layout/views';\nimport { AXPStateMessageComponent } from '@acorex-platform/framework-client/layout/components';\nimport { AXValueChangedEvent } from '@acorex/cdk/common';\nimport { AXSelectionListModule } from '@acorex/components/selection-list';\nimport { AXSkeletonModule } from '@acorex/components/skeleton';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { AsyncPipe } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { isEqual } from 'lodash-es';\nimport { resolvePersistedEntityId } from '../../../permissions/resolve-persisted-entity-id.util';\nimport { AXMUserRoleGrantService } from '../../user-role-grant.service';\nimport type { UserRoleGrantRow, UserRoleOption } from '../../user-role-grant.types';\n\n//#endregion\n\n//#region ----- Constants -----\n\nconst USER_ROLES_DISCARD_COMMAND = 'User:Roles:Discard';\nconst USER_ROLES_SAVE_COMMAND = 'User:Roles:Save';\n\n//#endregion\n\n//#region ----- Component -----\n\n/**\n * User detail/create wizard page that edits scoped UserRole assignments.\n */\n@Component({\n selector: 'axm-user-roles-page',\n standalone: true,\n imports: [\n AXPStateMessageComponent,\n AXSelectionListModule,\n AXSkeletonModule,\n AXTranslationModule,\n AsyncPipe,\n FormsModule,\n ],\n templateUrl: './user-roles-page.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: AXPPageLayoutBase,\n useExisting: AXMUserRolesPageComponent,\n },\n ],\n host: {\n class: 'flex h-full min-h-0 flex-1 flex-col overflow-hidden',\n },\n})\nexport class AXMUserRolesPageComponent extends AXPPageLayoutBaseComponent {\n //#region ----- Inputs -----\n\n rootContext = input<Record<string, unknown>>();\n pageConfig = input<Record<string, unknown>>();\n\n //#endregion\n\n //#region ----- Services & Dependencies -----\n\n private readonly grantService = inject(AXMUserRoleGrantService);\n private readonly hostPageLayout = inject(AXPPageLayoutBase, { optional: true, skipSelf: true });\n\n //#endregion\n\n //#region ----- State Signals -----\n\n private readonly loadedUserId = signal<string | undefined>(undefined);\n private readonly existingGrant = signal<UserRoleGrantRow | null>(null);\n private readonly baselineRoleIds = signal<string[]>([]);\n protected readonly currentRoleIds = signal<string[]>([]);\n protected readonly roleOptions = signal<UserRoleOption[]>([]);\n protected readonly isLoading = signal(true);\n\n //#endregion\n\n //#region ----- Computed Properties -----\n\n protected readonly userId = computed(() => resolvePersistedEntityId(this.rootContext()));\n\n protected readonly isDirty = computed(() => {\n return !this.areRoleSetsEqual(this.baselineRoleIds(), this.currentRoleIds());\n });\n\n /** System UserRole grants are seeded and not editable in product/platform UI. */\n protected readonly isGrantReadonly = computed(() => {\n const state = this.existingGrant()?.stateInfo;\n return state?.isSystem === true || state?.isImmutable === true;\n });\n\n /** Checkbox + label row placeholders for the loading skeleton */\n protected readonly roleSkeletonPlaceholders = computed(() => [\n 'w-40',\n 'w-28',\n 'w-48',\n 'w-32',\n 'w-44',\n 'w-36',\n 'w-40',\n 'w-52',\n ]);\n\n //#endregion\n\n //#region ----- Lifecycle -----\n\n constructor() {\n super();\n effect(() => {\n const id = this.userId();\n untracked(() => {\n void this.loadGrantForUser(id);\n });\n });\n }\n\n //#endregion\n\n //#region ----- Unsaved Changes -----\n\n override hasUnsavedChanges(): boolean {\n return this.isDirty();\n }\n\n //#endregion\n\n //#region ----- Page Actions -----\n\n override async getPrimaryMenuItems(): Promise<AXPActionMenuItem[]> {\n const discardTitle = (await this.translateService.translateAsync('@general:actions.discard.title')) || 'Discard';\n const saveTitle = (await this.translateService.translateAsync('@general:actions.save.title')) || 'Save';\n const canEdit = !!this.userId() && !this.isLoading() && !this.isGrantReadonly();\n\n const discardAction: AXPLayoutDetailsViewAction = {\n title: discardTitle,\n icon: 'fa-light fa-rotate-left',\n zone: 'footer',\n priority: 'secondary',\n color: 'default',\n visible: canEdit && this.isDirty(),\n command: { name: USER_ROLES_DISCARD_COMMAND, options: {} },\n };\n\n const saveAction: AXPLayoutDetailsViewAction = {\n title: saveTitle,\n icon: 'fa-light fa-floppy-disk',\n zone: 'footer',\n priority: 'primary',\n color: 'primary',\n visible: canEdit && this.isDirty(),\n command: { name: USER_ROLES_SAVE_COMMAND, options: {} },\n };\n\n return [discardAction, saveAction];\n }\n\n //#endregion\n\n //#region ----- Command Handling -----\n\n override execute(command: AXPExecuteCommand): void | Promise<void> {\n if (command.name === USER_ROLES_DISCARD_COMMAND) {\n this.handleDiscard();\n return;\n }\n if (command.name !== USER_ROLES_SAVE_COMMAND) {\n return;\n }\n return this.handleSaveExecute() as unknown as Promise<void>;\n }\n\n private async handleSaveExecute(): AXPCommandExecuteResultPromise {\n const userId = this.userId();\n const scope = this.grantService.resolveSessionScope();\n\n if (!userId || !scope) {\n return {\n success: false,\n message: {\n text: await this.translateService.translateAsync('@general:messages.entity.invalid-data'),\n },\n };\n }\n\n try {\n const roleIds = [...this.currentRoleIds()];\n const saved = await this.grantService.saveGrant({\n existing: this.existingGrant(),\n userId,\n roleIds,\n tenantId: scope.tenantId,\n applicationId: scope.applicationId,\n });\n\n const nextGrant: UserRoleGrantRow = {\n id: String(saved['id'] ?? this.existingGrant()?.id ?? ''),\n userId,\n roleIds,\n scopeInfo: (saved['scopeInfo'] as UserRoleGrantRow['scopeInfo']) ?? this.existingGrant()?.scopeInfo,\n };\n this.existingGrant.set(nextGrant.id ? nextGrant : this.existingGrant());\n this.baselineRoleIds.set([...roleIds]);\n this.currentRoleIds.set([...roleIds]);\n this.grantService.notifyGrantModified(saved);\n this.recompute();\n\n return {\n success: true,\n kind: 'object',\n data: roleIds,\n } as AXPRuntimeCommandResult;\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Failed to save roles.';\n return {\n success: false,\n message: { text: message },\n };\n }\n }\n\n //#endregion\n\n //#region ----- Event Handlers -----\n\n protected onRolesValueChanged(event: AXValueChangedEvent): void {\n if (!event.isUserInteraction || this.isGrantReadonly()) {\n return;\n }\n\n const next = Array.isArray(event.value)\n ? event.value.map(String)\n : event.value != null\n ? [String(event.value)]\n : [];\n\n this.currentRoleIds.set(next);\n this.recompute();\n }\n\n private handleDiscard(): void {\n this.currentRoleIds.set([...this.baselineRoleIds()]);\n this.recompute();\n }\n\n //#endregion\n\n //#region ----- Wizard step context -----\n\n override getWizardStepContext(): Record<string, unknown> | null {\n return null;\n }\n\n //#endregion\n\n //#region ----- Data Loading -----\n\n private async loadGrantForUser(userId: string | undefined): Promise<void> {\n if (!userId) {\n this.loadedUserId.set(undefined);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.roleOptions.set([]);\n this.isLoading.set(false);\n this.recompute();\n return;\n }\n\n if (userId === this.loadedUserId() && !this.isLoading()) {\n return;\n }\n\n this.isLoading.set(true);\n this.recompute();\n\n const scope = this.grantService.resolveSessionScope();\n if (!scope) {\n this.loadedUserId.set(userId);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.isLoading.set(false);\n this.recompute();\n return;\n }\n\n try {\n const grant = await this.grantService.findGrant(userId, scope.tenantId, scope.applicationId);\n const roleIds = [...(grant?.roleIds ?? [])];\n const options = await this.grantService.listRoleOptions(roleIds);\n this.loadedUserId.set(userId);\n this.existingGrant.set(grant);\n this.baselineRoleIds.set(roleIds);\n this.currentRoleIds.set([...roleIds]);\n this.roleOptions.set(options);\n } catch {\n this.loadedUserId.set(userId);\n this.existingGrant.set(null);\n this.baselineRoleIds.set([]);\n this.currentRoleIds.set([]);\n this.roleOptions.set([]);\n } finally {\n this.isLoading.set(false);\n this.recompute();\n }\n }\n\n //#endregion\n\n //#region ----- Utility Methods -----\n\n private areRoleSetsEqual(a: string[], b: string[]): boolean {\n return isEqual([...a].sort(), [...b].sort());\n }\n\n protected override recompute(): void {\n super.recompute();\n const maybeLayout = this.hostPageLayout as unknown as { recompute?: () => void };\n maybeLayout?.recompute?.();\n }\n\n //#endregion\n}\n\n//#endregion\n","@if (isLoading()) {\n <!-- ----- Skeleton while UserRole grant loads for the current workspace ----- -->\n <div class=\"flex h-full min-h-0 flex-1 flex-col overflow-auto p-4\" aria-hidden=\"true\">\n <div class=\"user-roles-frame rounded border border-default bg-lightest p-4\">\n <div class=\"mb-4 h-4 w-3/5 max-w-md rounded-md overflow-hidden\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n <div class=\"flex flex-col gap-3\">\n @for (widthClass of roleSkeletonPlaceholders(); track $index) {\n <!-- ----- One checkbox + label row placeholder ----- -->\n <div class=\"flex items-center gap-3\">\n <div class=\"h-4 w-4 shrink-0 rounded-sm overflow-hidden\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n <div class=\"h-4 max-w-full rounded-md overflow-hidden\" [class]=\"widthClass\">\n <ax-skeleton\n [animated]=\"true\"\n style=\"display: block; width: 100%; height: 100%\"\n ></ax-skeleton>\n </div>\n </div>\n }\n </div>\n </div>\n </div>\n}\n<!-- ----- User must be persisted before role grants can be edited ----- -->\n@else if (!userId()) {\n <div class=\"flex h-full min-h-[20rem] items-center justify-center p-6\">\n <axp-state-message\n [title]=\"'@security-management:users.entities.user.pages.roles.save-user-first.title'\"\n [description]=\"'@security-management:users.entities.user.pages.roles.save-user-first.description'\"\n ></axp-state-message>\n </div>\n}\n<!-- ----- Scoped role checklist for the current tenant/application ----- -->\n@else {\n <div class=\"flex h-full min-h-0 flex-1 flex-col overflow-auto p-4\">\n <div class=\"user-roles-frame rounded border border-default bg-lightest p-4\">\n <p class=\"mb-4 text-sm opacity-70\">\n {{ '@security-management:users.entities.user.pages.roles.description' | translate | async }}\n </p>\n <ax-selection-list\n class=\"w-full\"\n valueField=\"id\"\n textField=\"title\"\n look=\"solid\"\n direction=\"vertical\"\n [multiple]=\"true\"\n [showControl]=\"true\"\n [items]=\"roleOptions()\"\n [ngModel]=\"currentRoleIds()\"\n [disabled]=\"isGrantReadonly()\"\n [readonly]=\"isGrantReadonly()\"\n (onValueChanged)=\"onRolesValueChanged($event)\"\n ></ax-selection-list>\n </div>\n </div>\n}\n","//#region ----- Imports -----\n\nimport {\n AXPPageComponentDefinition,\n AXPPageComponentProvider,\n} from '@acorex-platform/framework-client/layout/components';\nimport { USER_ROLES_PAGE_COMPONENT_KEY } from '@acorex-platform/module-security-management-client/contracts';\nimport { Injectable } from '@angular/core';\n\n//#endregion\n\n//#region ----- Provider -----\n\n@Injectable()\nexport class AXMUserRolesPageComponentProvider implements AXPPageComponentProvider {\n async components(): Promise<AXPPageComponentDefinition[]> {\n return [\n {\n key: USER_ROLES_PAGE_COMPONENT_KEY,\n loader: () =>\n import('./user-roles-page.component').then((m) => m.AXMUserRolesPageComponent),\n },\n ];\n }\n}\n\n//#endregion\n"],"names":["i2","i3","i4"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAiBA;AAEA;AAEA;;;AAGG;MAEU,uBAAuB,CAAA;AADpC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,kCAAkC,CAAC;AAC3D,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,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A,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAeA,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAvBrC,SAAS;+BACE,qBAAqB,EAAA,UAAA,EACnB,IAAI,EAAA,OAAA,EACP;wBACP,wBAAwB;wBACxB,qBAAqB;wBACrB,gBAAgB;wBAChB,mBAAmB;wBACnB,SAAS;wBACT,WAAW;qBACZ,EAAA,eAAA,EAEgB,uBAAuB,CAAC,MAAM,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAA,yBAA2B;AACvC,yBAAA;qBACF,EAAA,IAAA,EACK;AACJ,wBAAA,KAAK,EAAE,qDAAqD;AAC7D,qBAAA,EAAA,QAAA,EAAA,gpFAAA,EAAA;;;;;;;;AE1DH;AAEA;MAGa,iCAAiC,CAAA;AAC5C,IAAA,MAAM,UAAU,GAAA;QACd,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,6BAA6B;AAClC,gBAAA,MAAM,EAAE,MACN,uEAAqC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,yBAAyB,CAAC;AACjF,aAAA;SACF;IACH;8GATW,iCAAiC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAjC,iCAAiC,EAAA,CAAA,CAAA;;2FAAjC,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAD7C;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region ----- Types -----
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region ----- Resolve targets -----
|
|
4
|
+
/**
|
|
5
|
+
* Map entity-action payload to invite targets.
|
|
6
|
+
* - Users list row: `data.id` is User id (no `data.userId`)
|
|
7
|
+
* - TenantUser list row: `data.id` is TenantUser id and `data.userId` is User id
|
|
8
|
+
*/
|
|
9
|
+
function resolveInvitationCommandTargets(input = {}) {
|
|
10
|
+
const explicitTenantUserId = input.tenantUserId?.trim();
|
|
11
|
+
if (explicitTenantUserId) {
|
|
12
|
+
return {
|
|
13
|
+
tenantUserId: explicitTenantUserId,
|
|
14
|
+
userId: input.userId?.trim() || input.data?.userId?.trim() || undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const explicitUserId = input.userId?.trim();
|
|
18
|
+
if (explicitUserId) {
|
|
19
|
+
return { userId: explicitUserId };
|
|
20
|
+
}
|
|
21
|
+
const data = input.data;
|
|
22
|
+
if (!data) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
const rowUserId = typeof data.userId === 'string' ? data.userId.trim() : '';
|
|
26
|
+
const rowId = typeof data.id === 'string' ? data.id.trim() : '';
|
|
27
|
+
if (rowUserId) {
|
|
28
|
+
return {
|
|
29
|
+
tenantUserId: rowId || undefined,
|
|
30
|
+
userId: rowUserId,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (rowId) {
|
|
34
|
+
return { userId: rowId };
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
|
|
40
|
+
export { resolveInvitationCommandTargets as r };
|
|
41
|
+
//# sourceMappingURL=acorex-platform-module-security-management-client-invitation-target.util-BAXQZwLW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-security-management-client-invitation-target.util-BAXQZwLW.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/commands/invitation-target.util.ts"],"sourcesContent":["//#region ----- Types -----\n\nexport interface AXPInvitationTargetCommandInput {\n tenantUserId?: string;\n userId?: string;\n data?: { id?: string; userId?: string; displayName?: string; email?: string };\n}\n\n//#endregion\n\n//#region ----- Resolve targets -----\n\n/**\n * Map entity-action payload to invite targets.\n * - Users list row: `data.id` is User id (no `data.userId`)\n * - TenantUser list row: `data.id` is TenantUser id and `data.userId` is User id\n */\nexport function resolveInvitationCommandTargets(\n input: AXPInvitationTargetCommandInput = {},\n): { tenantUserId?: string; userId?: string } {\n const explicitTenantUserId = input.tenantUserId?.trim();\n if (explicitTenantUserId) {\n return {\n tenantUserId: explicitTenantUserId,\n userId: input.userId?.trim() || input.data?.userId?.trim() || undefined,\n };\n }\n\n const explicitUserId = input.userId?.trim();\n if (explicitUserId) {\n return { userId: explicitUserId };\n }\n\n const data = input.data;\n if (!data) {\n return {};\n }\n\n const rowUserId = typeof data.userId === 'string' ? data.userId.trim() : '';\n const rowId = typeof data.id === 'string' ? data.id.trim() : '';\n\n if (rowUserId) {\n return {\n tenantUserId: rowId || undefined,\n userId: rowUserId,\n };\n }\n\n if (rowId) {\n return { userId: rowId };\n }\n\n return {};\n}\n\n//#endregion\n"],"names":[],"mappings":"AAAA;AAQA;AAEA;AAEA;;;;AAIG;AACG,SAAU,+BAA+B,CAC7C,KAAA,GAAyC,EAAE,EAAA;IAE3C,MAAM,oBAAoB,GAAG,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO;AACL,YAAA,YAAY,EAAE,oBAAoB;AAClC,YAAA,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS;SACxE;IACH;IAEA,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE;IAC3C,IAAI,cAAc,EAAE;AAClB,QAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE;IACnC;AAEA,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI;IACvB,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IAC3E,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE;IAE/D,IAAI,SAAS,EAAE;QACb,OAAO;YACL,YAAY,EAAE,KAAK,IAAI,SAAS;AAChC,YAAA,MAAM,EAAE,SAAS;SAClB;IACH;IAEA,IAAI,KAAK,EAAE;AACT,QAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;IAC1B;AAEA,IAAA,OAAO,EAAE;AACX;AAEA;;"}
|
package/fesm2022/acorex-platform-module-security-management-client-invite-user.command-kFXjLdxy.mjs
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { AXDialogService } from '@acorex/components/dialog';
|
|
2
|
+
import { AXToastService } from '@acorex/components/toast';
|
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
|
4
|
+
import { AXPLayoutBuilderService, resolveLayoutBuilderDialogResult } from '@acorex-platform/framework-client/layout/builder';
|
|
5
|
+
import { AXPCommandService } from '@acorex-platform/framework-client/runtime';
|
|
6
|
+
import { AXMSecurityManagementServerCommands } from '@acorex-platform/module-security-management-client/contracts';
|
|
7
|
+
export { AXM_USER_INVITE_COMMAND } from '@acorex-platform/module-security-management-client/contracts';
|
|
8
|
+
import * as i0 from '@angular/core';
|
|
9
|
+
import { inject, Injectable } from '@angular/core';
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region ---- Invite user command ----
|
|
13
|
+
class AXPInviteUserCommand {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.layoutBuilder = inject(AXPLayoutBuilderService);
|
|
16
|
+
this.commandService = inject(AXPCommandService);
|
|
17
|
+
this.dialogService = inject(AXDialogService);
|
|
18
|
+
this.toastService = inject(AXToastService);
|
|
19
|
+
this.translationService = inject(AXTranslationService);
|
|
20
|
+
}
|
|
21
|
+
async execute() {
|
|
22
|
+
const form = await this.openInviteDialog();
|
|
23
|
+
if (!form) {
|
|
24
|
+
return { success: true, kind: 'object', data: { outcome: 'cancelled' } };
|
|
25
|
+
}
|
|
26
|
+
const webOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;
|
|
27
|
+
// Nested server call must skip toast middleware — this command owns UX toasts.
|
|
28
|
+
let result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.InviteUser, {
|
|
29
|
+
email: form.email,
|
|
30
|
+
displayName: form.displayName,
|
|
31
|
+
applicationIds: form.applicationIds,
|
|
32
|
+
webOrigin,
|
|
33
|
+
});
|
|
34
|
+
const payload = result?.data;
|
|
35
|
+
if (result?.success && payload?.userAlreadyExists && !payload.sent) {
|
|
36
|
+
const title = await this.translationService
|
|
37
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.existing-warning-title')
|
|
38
|
+
.catch(() => 'User Already Exists');
|
|
39
|
+
const message = await this.translationService
|
|
40
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.existing-warning-message', {
|
|
41
|
+
params: { email: form.email },
|
|
42
|
+
})
|
|
43
|
+
.catch(() => `A user with email ${form.email} already exists. Send an invitation to join this tenant?`);
|
|
44
|
+
const confirmed = await this.dialogService.confirm(title, message, 'warning', 'horizontal');
|
|
45
|
+
if (!confirmed.result) {
|
|
46
|
+
return { success: true, kind: 'object', data: { outcome: 'cancelled' } };
|
|
47
|
+
}
|
|
48
|
+
result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.InviteUser, {
|
|
49
|
+
email: form.email,
|
|
50
|
+
displayName: form.displayName,
|
|
51
|
+
applicationIds: form.applicationIds,
|
|
52
|
+
confirmExisting: true,
|
|
53
|
+
webOrigin,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (result?.success) {
|
|
57
|
+
const [toastTitle, toastContent] = await Promise.all([
|
|
58
|
+
this.translationService
|
|
59
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.success.title')
|
|
60
|
+
.catch(() => 'Invitation Sent'),
|
|
61
|
+
this.translationService
|
|
62
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.success.description')
|
|
63
|
+
.catch(() => 'The invitation email was sent.'),
|
|
64
|
+
]);
|
|
65
|
+
this.toastService.show({ color: 'success', title: toastTitle, content: toastContent, timeOut: 3000 });
|
|
66
|
+
return { success: true, kind: 'object', data: result.data };
|
|
67
|
+
}
|
|
68
|
+
const [toastTitle, fallback] = await Promise.all([
|
|
69
|
+
this.translationService
|
|
70
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.error.title')
|
|
71
|
+
.catch(() => 'Invite Failed'),
|
|
72
|
+
this.translationService
|
|
73
|
+
.translateAsync('@security-management:users.entities.user.actions.invite.error.description')
|
|
74
|
+
.catch(() => 'Failed to invite user.'),
|
|
75
|
+
]);
|
|
76
|
+
const toastContent = (typeof result?.message?.text === 'string' && result.message.text) || fallback;
|
|
77
|
+
this.toastService.show({ color: 'danger', title: toastTitle, content: toastContent, timeOut: 4000 });
|
|
78
|
+
// No `message` — outer command toast middleware would duplicate this toast.
|
|
79
|
+
return { success: false };
|
|
80
|
+
}
|
|
81
|
+
async openInviteDialog() {
|
|
82
|
+
const result = await this.layoutBuilder
|
|
83
|
+
.create()
|
|
84
|
+
.dialog((dialog) => {
|
|
85
|
+
dialog
|
|
86
|
+
.setTitle('@security-management:users.entities.user.actions.invite.dialog.title')
|
|
87
|
+
.setSize('md')
|
|
88
|
+
.setCloseButton(true)
|
|
89
|
+
.setContext({ email: '', displayName: '', applicationIds: [] })
|
|
90
|
+
.content((flex) => {
|
|
91
|
+
flex
|
|
92
|
+
.setDirection('column')
|
|
93
|
+
.setGap('12px')
|
|
94
|
+
.formField('@security-management:users.entities.user.actions.invite.fields.email', (field) => {
|
|
95
|
+
field.path('email');
|
|
96
|
+
field.textBox({ validations: [{ rule: 'required' }, { rule: 'email' }] });
|
|
97
|
+
})
|
|
98
|
+
.formField('@security-management:users.entities.user.actions.invite.fields.display-name', (field) => {
|
|
99
|
+
field.path('displayName');
|
|
100
|
+
field.textBox({});
|
|
101
|
+
})
|
|
102
|
+
.formField('@security-management:users.entities.user.actions.invite.fields.applications', (field) => {
|
|
103
|
+
field.path('applicationIds');
|
|
104
|
+
field.lookupBox({
|
|
105
|
+
entity: 'ApplicationManagement.Application',
|
|
106
|
+
multiple: true,
|
|
107
|
+
look: 'select',
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
})
|
|
111
|
+
.setActions((actions) => {
|
|
112
|
+
actions.cancel('@general:actions.cancel.title');
|
|
113
|
+
actions.submit('@security-management:users.entities.user.actions.invite.dialog.submit');
|
|
114
|
+
})
|
|
115
|
+
.onAction(async (dialogRef) => {
|
|
116
|
+
if (dialogRef.action() === 'cancel') {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const ctx = dialogRef.context();
|
|
120
|
+
const email = (ctx.email ?? '').trim();
|
|
121
|
+
if (!email) {
|
|
122
|
+
throw new Error('@security-management:users.entities.user.actions.invite.errors.email-required');
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
email,
|
|
126
|
+
displayName: (ctx.displayName ?? '').trim() || undefined,
|
|
127
|
+
applicationIds: Array.isArray(ctx.applicationIds) ? ctx.applicationIds : undefined,
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
})
|
|
131
|
+
.show();
|
|
132
|
+
return resolveLayoutBuilderDialogResult(result);
|
|
133
|
+
}
|
|
134
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPInviteUserCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
135
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPInviteUserCommand, providedIn: 'root' }); }
|
|
136
|
+
}
|
|
137
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPInviteUserCommand, decorators: [{
|
|
138
|
+
type: Injectable,
|
|
139
|
+
args: [{ providedIn: 'root' }]
|
|
140
|
+
}] });
|
|
141
|
+
|
|
142
|
+
export { AXPInviteUserCommand };
|
|
143
|
+
//# sourceMappingURL=acorex-platform-module-security-management-client-invite-user.command-kFXjLdxy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-security-management-client-invite-user.command-kFXjLdxy.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/commands/invite-user.command.ts"],"sourcesContent":["import { AXDialogService } from '@acorex/components/dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport {\n AXPLayoutBuilderService,\n resolveLayoutBuilderDialogResult,\n} from '@acorex-platform/framework-client/layout/builder';\nimport { AXPCommandService } from '@acorex-platform/framework-client/runtime';\nimport type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport {\n AXM_USER_INVITE_COMMAND,\n AXMSecurityManagementServerCommands,\n type AXMInviteUserResult,\n} from '@acorex-platform/module-security-management-client/contracts';\nimport { inject, Injectable } from '@angular/core';\n\n//#region ---- Types ----\n\ninterface InviteFormResult {\n email: string;\n displayName?: string;\n applicationIds?: string[];\n}\n\n//#endregion\n\n//#region ---- Invite user command ----\n\n@Injectable({ providedIn: 'root' })\nexport class AXPInviteUserCommand implements AXPCommand {\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly commandService = inject(AXPCommandService);\n private readonly dialogService = inject(AXDialogService);\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n\n async execute(): AXPCommandExecuteResultPromise {\n const form = await this.openInviteDialog();\n if (!form) {\n return { success: true, kind: 'object', data: { outcome: 'cancelled' } };\n }\n\n const webOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;\n // Nested server call must skip toast middleware — this command owns UX toasts.\n let result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.InviteUser, {\n email: form.email,\n displayName: form.displayName,\n applicationIds: form.applicationIds,\n webOrigin,\n });\n\n const payload = (result as { data?: AXMInviteUserResult })?.data;\n if (result?.success && payload?.userAlreadyExists && !payload.sent) {\n const title = await this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.existing-warning-title')\n .catch(() => 'User Already Exists');\n const message = await this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.existing-warning-message', {\n params: { email: form.email },\n })\n .catch(() => `A user with email ${form.email} already exists. Send an invitation to join this tenant?`);\n const confirmed = await this.dialogService.confirm(title, message, 'warning', 'horizontal');\n if (!confirmed.result) {\n return { success: true, kind: 'object', data: { outcome: 'cancelled' } };\n }\n result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.InviteUser, {\n email: form.email,\n displayName: form.displayName,\n applicationIds: form.applicationIds,\n confirmExisting: true,\n webOrigin,\n });\n }\n\n if (result?.success) {\n const [toastTitle, toastContent] = await Promise.all([\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.success.title')\n .catch(() => 'Invitation Sent'),\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.success.description')\n .catch(() => 'The invitation email was sent.'),\n ]);\n this.toastService.show({ color: 'success', title: toastTitle, content: toastContent, timeOut: 3000 });\n return { success: true, kind: 'object', data: result.data };\n }\n\n const [toastTitle, fallback] = await Promise.all([\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.error.title')\n .catch(() => 'Invite Failed'),\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.invite.error.description')\n .catch(() => 'Failed to invite user.'),\n ]);\n const toastContent =\n (typeof result?.message?.text === 'string' && result.message.text) || fallback;\n this.toastService.show({ color: 'danger', title: toastTitle, content: toastContent, timeOut: 4000 });\n // No `message` — outer command toast middleware would duplicate this toast.\n return { success: false };\n }\n\n private async openInviteDialog(): Promise<InviteFormResult | null> {\n const result = await this.layoutBuilder\n .create()\n .dialog<InviteFormResult | null>((dialog) => {\n dialog\n .setTitle('@security-management:users.entities.user.actions.invite.dialog.title')\n .setSize('md')\n .setCloseButton(true)\n .setContext({ email: '', displayName: '', applicationIds: [] })\n .content((flex) => {\n flex\n .setDirection('column')\n .setGap('12px')\n .formField('@security-management:users.entities.user.actions.invite.fields.email', (field) => {\n field.path('email');\n field.textBox({ validations: [{ rule: 'required' }, { rule: 'email' }] });\n })\n .formField('@security-management:users.entities.user.actions.invite.fields.display-name', (field) => {\n field.path('displayName');\n field.textBox({});\n })\n .formField('@security-management:users.entities.user.actions.invite.fields.applications', (field) => {\n field.path('applicationIds');\n field.lookupBox({\n entity: 'ApplicationManagement.Application',\n multiple: true,\n look: 'select',\n });\n });\n })\n .setActions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n actions.submit('@security-management:users.entities.user.actions.invite.dialog.submit');\n })\n .onAction(async (dialogRef) => {\n if (dialogRef.action() === 'cancel') {\n return null;\n }\n const ctx = dialogRef.context() as InviteFormResult;\n const email = (ctx.email ?? '').trim();\n if (!email) {\n throw new Error('@security-management:users.entities.user.actions.invite.errors.email-required');\n }\n return {\n email,\n displayName: (ctx.displayName ?? '').trim() || undefined,\n applicationIds: Array.isArray(ctx.applicationIds) ? ctx.applicationIds : undefined,\n };\n });\n })\n .show();\n\n return resolveLayoutBuilderDialogResult<InviteFormResult>(result);\n }\n}\n\nexport { AXM_USER_INVITE_COMMAND };\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;AAwBA;AAEA;MAGa,oBAAoB,CAAA;AADjC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC;AACvC,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0HnE,IAAA;AAxHC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AAmB,MAAM,CAAC;IACnE;8GA9HW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cADP,MAAM,EAAA,CAAA,CAAA;;2FACnB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;"}
|
|
@@ -23,6 +23,7 @@ function provideSecurityManagementLocalEntities() {
|
|
|
23
23
|
[RootConfig.entities.roles.name]: () => import('@acorex-platform/module-security-management-client/contracts/entities/roles').then((m) => m.rolesFactory()),
|
|
24
24
|
[RootConfig.entities.userRole.name]: () => import('@acorex-platform/module-security-management-client/contracts/entities/user-role').then((m) => m.userRoleFactory()),
|
|
25
25
|
[RootConfig.entities.users.name]: () => import('@acorex-platform/module-security-management-client/contracts/entities/users').then((m) => m.usersFactory()),
|
|
26
|
+
[RootConfig.entities.userTwoFactor.name]: () => import('@acorex-platform/module-security-management-client/contracts/entities/user-two-factor').then((m) => m.userTwoFactorFactory()),
|
|
26
27
|
},
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acorex-platform-module-security-management-client-local-entities.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/provide-local-entities.ts","../../../../libs/modules/security-management/client/src/lib/acorex-platform-module-security-management-client-local-entities.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { provideLocalEntityCatalog } from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-security-management-client/contracts';\n\n//#endregion\n\n//#region ----- Provide local entities -----\n\n/**\n * Registers security-management layouts on the client from packaged factories.\n * Each `import()` targets a secondary entry so unused entities stay out of the\n * bundle. Do not add this to the demo app; demo continues to load layouts via\n * `Domain:GetEntityLayout`.\n */\nexport function provideSecurityManagementLocalEntities() {\n return provideLocalEntityCatalog({\n moduleName: RootConfig.module.name,\n loaders: {\n [RootConfig.entities.deviceSessions.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/device-sessions').then((m) => m.deviceSessionsFactory()),\n [RootConfig.entities.identityProvider.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/identity-provider').then((m) => m.identityProviderFactory()),\n [RootConfig.entities.policy.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/policy').then((m) => m.policyFactory()),\n [RootConfig.entities.profile.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/profile').then((m) => m.profileFactory()),\n [RootConfig.entities.rolePermission.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/role-permission').then((m) => m.rolePermissionFactory()),\n [RootConfig.entities.roles.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/roles').then((m) => m.rolesFactory()),\n [RootConfig.entities.userRole.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/user-role').then((m) => m.userRoleFactory()),\n [RootConfig.entities.users.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/users').then((m) => m.usersFactory()),\n },\n });\n}\n\nexport { securityManagementLocalEntityCatalog } from '@acorex-platform/module-security-management-client/contracts/entity-catalog';\n\n//#endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './provide-local-entities';\n"],"names":[],"mappings":";;;;AAAA;AAKA;AAEA;AAEA;;;;;AAKG;SACa,sCAAsC,GAAA;AACpD,IAAA,OAAO,yBAAyB,CAAC;AAC/B,QAAA,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI;AAClC,QAAA,OAAO,EAAE;AACP,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,MACzC,OAAO,uF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,"file":"acorex-platform-module-security-management-client-local-entities.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/provide-local-entities.ts","../../../../libs/modules/security-management/client/src/lib/acorex-platform-module-security-management-client-local-entities.ts"],"sourcesContent":["//#region ----- Imports -----\n\nimport { provideLocalEntityCatalog } from '@acorex-platform/framework-client/layout/entity';\nimport { RootConfig } from '@acorex-platform/module-security-management-client/contracts';\n\n//#endregion\n\n//#region ----- Provide local entities -----\n\n/**\n * Registers security-management layouts on the client from packaged factories.\n * Each `import()` targets a secondary entry so unused entities stay out of the\n * bundle. Do not add this to the demo app; demo continues to load layouts via\n * `Domain:GetEntityLayout`.\n */\nexport function provideSecurityManagementLocalEntities() {\n return provideLocalEntityCatalog({\n moduleName: RootConfig.module.name,\n loaders: {\n [RootConfig.entities.deviceSessions.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/device-sessions').then((m) => m.deviceSessionsFactory()),\n [RootConfig.entities.identityProvider.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/identity-provider').then((m) => m.identityProviderFactory()),\n [RootConfig.entities.policy.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/policy').then((m) => m.policyFactory()),\n [RootConfig.entities.profile.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/profile').then((m) => m.profileFactory()),\n [RootConfig.entities.rolePermission.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/role-permission').then((m) => m.rolePermissionFactory()),\n [RootConfig.entities.roles.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/roles').then((m) => m.rolesFactory()),\n [RootConfig.entities.userRole.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/user-role').then((m) => m.userRoleFactory()),\n [RootConfig.entities.users.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/users').then((m) => m.usersFactory()),\n [RootConfig.entities.userTwoFactor.name]: () =>\n import('@acorex-platform/module-security-management-client/contracts/entities/user-two-factor').then(\n (m) => m.userTwoFactorFactory(),\n ),\n },\n });\n}\n\nexport { securityManagementLocalEntityCatalog } from '@acorex-platform/module-security-management-client/contracts/entity-catalog';\n\n//#endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './provide-local-entities';\n"],"names":[],"mappings":";;;;AAAA;AAKA;AAEA;AAEA;;;;;AAKG;SACa,sCAAsC,GAAA;AACpD,IAAA,OAAO,yBAAyB,CAAC;AAC/B,QAAA,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI;AAClC,QAAA,OAAO,EAAE;AACP,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,MACzC,OAAO,uFAAuF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,qBAAqB,EAAE,CAAC;AACxI,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,GAAG,MAC3C,OAAO,yFAAyF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC5I,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,MACjC,OAAO,8EAA8E,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;AACvH,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,MAClC,OAAO,+EAA+E,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC;AACzH,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,MACzC,OAAO,uFAAuF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,qBAAqB,EAAE,CAAC;AACxI,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,MAChC,OAAO,6EAA6E,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;AACrH,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAAG,MACnC,OAAO,iFAAiF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,CAAC;AAC5H,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,MAChC,OAAO,6EAA6E,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;AACrH,YAAA,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,GAAG,MACxC,OAAO,uFAAuF,CAAC,CAAC,IAAI,CAClG,CAAC,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,CAChC;AACJ,SAAA;AACF,KAAA,CAAC;AACJ;AAIA;;AC7CA;;AAEG;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AXDialogService } from '@acorex/components/dialog';
|
|
2
|
+
import { AXToastService } from '@acorex/components/toast';
|
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
|
4
|
+
import { AXPCommandService } from '@acorex-platform/framework-client/runtime';
|
|
5
|
+
import { AXMSecurityManagementServerCommands } from '@acorex-platform/module-security-management-client/contracts';
|
|
6
|
+
export { AXM_USER_RESEND_INVITATION_COMMAND } from '@acorex-platform/module-security-management-client/contracts';
|
|
7
|
+
import * as i0 from '@angular/core';
|
|
8
|
+
import { inject, Injectable } from '@angular/core';
|
|
9
|
+
import { r as resolveInvitationCommandTargets } from './acorex-platform-module-security-management-client-invitation-target.util-BAXQZwLW.mjs';
|
|
10
|
+
|
|
11
|
+
//#region ---- AXPResendInvitationCommand ----
|
|
12
|
+
class AXPResendInvitationCommand {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.dialogService = inject(AXDialogService);
|
|
15
|
+
this.toastService = inject(AXToastService);
|
|
16
|
+
this.translationService = inject(AXTranslationService);
|
|
17
|
+
this.commandService = inject(AXPCommandService);
|
|
18
|
+
}
|
|
19
|
+
async execute(input = {}) {
|
|
20
|
+
const { tenantUserId, userId } = resolveInvitationCommandTargets(input);
|
|
21
|
+
if (!tenantUserId && !userId) {
|
|
22
|
+
return { success: false, message: { text: 'Tenant user id is required.' } };
|
|
23
|
+
}
|
|
24
|
+
const who = input.data?.displayName || input.data?.email || String(tenantUserId || userId);
|
|
25
|
+
const confirmTitle = await this.translationService
|
|
26
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.confirm-title')
|
|
27
|
+
.catch(() => 'resend-invitation');
|
|
28
|
+
const confirmMessage = await this.translationService
|
|
29
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.confirm-message', {
|
|
30
|
+
params: { user: who },
|
|
31
|
+
})
|
|
32
|
+
.catch(() => `Continue for ${who}?`);
|
|
33
|
+
const confirmed = await this.dialogService.confirm(confirmTitle, confirmMessage, 'primary', 'horizontal');
|
|
34
|
+
if (!confirmed.result) {
|
|
35
|
+
return { success: false };
|
|
36
|
+
}
|
|
37
|
+
const webOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;
|
|
38
|
+
const result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.ResendInvitation, {
|
|
39
|
+
tenantUserId,
|
|
40
|
+
userId,
|
|
41
|
+
webOrigin,
|
|
42
|
+
});
|
|
43
|
+
if (result?.success) {
|
|
44
|
+
const [toastTitle, toastContent] = await Promise.all([
|
|
45
|
+
this.translationService
|
|
46
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.success.title')
|
|
47
|
+
.catch(() => 'Success'),
|
|
48
|
+
this.translationService
|
|
49
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.success.description')
|
|
50
|
+
.catch(() => 'Done.'),
|
|
51
|
+
]);
|
|
52
|
+
this.toastService.show({ color: 'success', title: toastTitle, content: toastContent, timeOut: 3000 });
|
|
53
|
+
return { success: true, kind: 'object', data: undefined };
|
|
54
|
+
}
|
|
55
|
+
const [toastTitle, fallback] = await Promise.all([
|
|
56
|
+
this.translationService
|
|
57
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.error.title')
|
|
58
|
+
.catch(() => 'Failed'),
|
|
59
|
+
this.translationService
|
|
60
|
+
.translateAsync('@security-management:users.entities.user.actions.resend-invitation.error.description')
|
|
61
|
+
.catch(() => 'The action failed.'),
|
|
62
|
+
]);
|
|
63
|
+
const toastContent = (typeof result?.message?.text === 'string' && result.message.text) || fallback;
|
|
64
|
+
this.toastService.show({ color: 'danger', title: toastTitle, content: toastContent, timeOut: 4000 });
|
|
65
|
+
return { success: false };
|
|
66
|
+
}
|
|
67
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPResendInvitationCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
68
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPResendInvitationCommand, providedIn: 'root' }); }
|
|
69
|
+
}
|
|
70
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPResendInvitationCommand, decorators: [{
|
|
71
|
+
type: Injectable,
|
|
72
|
+
args: [{ providedIn: 'root' }]
|
|
73
|
+
}] });
|
|
74
|
+
|
|
75
|
+
export { AXPResendInvitationCommand };
|
|
76
|
+
//# sourceMappingURL=acorex-platform-module-security-management-client-resend-invitation.command-D9Ijk565.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-security-management-client-resend-invitation.command-D9Ijk565.mjs","sources":["../../../../libs/modules/security-management/client/src/lib/commands/resend-invitation.command.ts"],"sourcesContent":["import { AXDialogService } from '@acorex/components/dialog';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPCommandService } from '@acorex-platform/framework-client/runtime';\nimport type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';\nimport {\n AXM_USER_RESEND_INVITATION_COMMAND,\n AXMSecurityManagementServerCommands,\n} from '@acorex-platform/module-security-management-client/contracts';\nimport { inject, Injectable } from '@angular/core';\nimport {\n resolveInvitationCommandTargets,\n type AXPInvitationTargetCommandInput,\n} from './invitation-target.util';\n\nexport type { AXPInvitationTargetCommandInput };\n\n//#region ---- AXPResendInvitationCommand ----\n\n@Injectable({ providedIn: 'root' })\nexport class AXPResendInvitationCommand implements AXPCommand<AXPInvitationTargetCommandInput> {\n private readonly dialogService = inject(AXDialogService);\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n private readonly commandService = inject(AXPCommandService);\n\n async execute(input: AXPInvitationTargetCommandInput = {}): AXPCommandExecuteResultPromise {\n const { tenantUserId, userId } = resolveInvitationCommandTargets(input);\n if (!tenantUserId && !userId) {\n return { success: false, message: { text: 'Tenant user id is required.' } };\n }\n\n const who = input.data?.displayName || input.data?.email || String(tenantUserId || userId);\n const confirmTitle = await this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.confirm-title')\n .catch(() => 'resend-invitation');\n const confirmMessage = await this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.confirm-message', {\n params: { user: who },\n })\n .catch(() => `Continue for ${who}?`);\n\n const confirmed = await this.dialogService.confirm(confirmTitle, confirmMessage, 'primary', 'horizontal');\n if (!confirmed.result) {\n return { success: false };\n }\n\n const webOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;\n const result = await this.commandService.executeRemote(AXMSecurityManagementServerCommands.ResendInvitation, {\n tenantUserId,\n userId,\n webOrigin,\n });\n\n if (result?.success) {\n const [toastTitle, toastContent] = await Promise.all([\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.success.title')\n .catch(() => 'Success'),\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.success.description')\n .catch(() => 'Done.'),\n ]);\n this.toastService.show({ color: 'success', title: toastTitle, content: toastContent, timeOut: 3000 });\n return { success: true, kind: 'object', data: undefined };\n }\n\n const [toastTitle, fallback] = await Promise.all([\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.error.title')\n .catch(() => 'Failed'),\n this.translationService\n .translateAsync('@security-management:users.entities.user.actions.resend-invitation.error.description')\n .catch(() => 'The action failed.'),\n ]);\n const toastContent =\n (typeof result?.message?.text === 'string' && result.message.text) || fallback;\n this.toastService.show({ color: 'danger', title: toastTitle, content: toastContent, timeOut: 4000 });\n return { success: false };\n }\n}\n\nexport { AXM_USER_RESEND_INVITATION_COMMAND };\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;AAiBA;MAGa,0BAA0B,CAAA;AADvC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC;AACvC,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AACjD,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAwD5D,IAAA;AAtDC,IAAA,MAAM,OAAO,CAAC,KAAA,GAAyC,EAAE,EAAA;QACvD,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,+BAA+B,CAAC,KAAK,CAAC;AACvE,QAAA,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM,EAAE;AAC5B,YAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,EAAE;QAC7E;QAEA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,WAAW,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,IAAI,MAAM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