@abpjs/identity 1.0.0 → 2.0.0
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/dist/index.d.mts +184 -35
- package/dist/index.d.ts +184 -35
- package/dist/index.js +189 -49
- package/dist/index.mjs +188 -48
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,50 @@ declare namespace Identity {
|
|
|
70
70
|
password: string;
|
|
71
71
|
roleNames: string[];
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Input props for RolesComponent
|
|
75
|
+
* @since 2.0.0
|
|
76
|
+
*/
|
|
77
|
+
interface RolesComponentInputs {
|
|
78
|
+
/** Callback when a role is created */
|
|
79
|
+
readonly onRoleCreated?: (role: RoleItem) => void;
|
|
80
|
+
/** Callback when a role is updated */
|
|
81
|
+
readonly onRoleUpdated?: (role: RoleItem) => void;
|
|
82
|
+
/** Callback when a role is deleted */
|
|
83
|
+
readonly onRoleDeleted?: (id: string) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Output callbacks for RolesComponent
|
|
87
|
+
* @since 2.0.0
|
|
88
|
+
*/
|
|
89
|
+
interface RolesComponentOutputs {
|
|
90
|
+
/** Callback when permission modal visibility changes */
|
|
91
|
+
readonly onVisiblePermissionChange?: (visible: boolean) => void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Input props for UsersComponent
|
|
95
|
+
* @since 2.0.0
|
|
96
|
+
*/
|
|
97
|
+
interface UsersComponentInputs {
|
|
98
|
+
/** Callback when a user is created */
|
|
99
|
+
readonly onUserCreated?: (user: UserItem) => void;
|
|
100
|
+
/** Callback when a user is updated */
|
|
101
|
+
readonly onUserUpdated?: (user: UserItem) => void;
|
|
102
|
+
/** Callback when a user is deleted */
|
|
103
|
+
readonly onUserDeleted?: (id: string) => void;
|
|
104
|
+
/** Password validation rules to display */
|
|
105
|
+
readonly passwordRulesArr?: ('number' | 'small' | 'capital' | 'special')[];
|
|
106
|
+
/** Required minimum password length */
|
|
107
|
+
readonly requiredPasswordLength?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Output callbacks for UsersComponent
|
|
111
|
+
* @since 2.0.0
|
|
112
|
+
*/
|
|
113
|
+
interface UsersComponentOutputs {
|
|
114
|
+
/** Callback when permission modal visibility changes */
|
|
115
|
+
readonly onVisiblePermissionChange?: (visible: boolean) => void;
|
|
116
|
+
}
|
|
73
117
|
}
|
|
74
118
|
|
|
75
119
|
/**
|
|
@@ -151,6 +195,118 @@ declare class IdentityService {
|
|
|
151
195
|
updateUser(id: string, body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
152
196
|
}
|
|
153
197
|
|
|
198
|
+
/**
|
|
199
|
+
* IdentityStateService - A stateful service facade for identity operations.
|
|
200
|
+
*
|
|
201
|
+
* This service provides a stateful wrapper around IdentityService, maintaining
|
|
202
|
+
* local state for roles and users. It's the React equivalent of Angular's
|
|
203
|
+
* IdentityStateService which wraps NGXS store operations.
|
|
204
|
+
*
|
|
205
|
+
* For most React use cases, prefer using the hooks (useRoles, useUsers, useIdentity)
|
|
206
|
+
* instead of this class. This class is provided for programmatic/non-hook scenarios.
|
|
207
|
+
*
|
|
208
|
+
* @since 2.0.0
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { IdentityStateService, IdentityService } from '@abpjs/identity';
|
|
213
|
+
* import { RestService } from '@abpjs/core';
|
|
214
|
+
*
|
|
215
|
+
* const rest = new RestService();
|
|
216
|
+
* const identityService = new IdentityService(rest);
|
|
217
|
+
* const stateService = new IdentityStateService(identityService);
|
|
218
|
+
*
|
|
219
|
+
* // Fetch and get roles
|
|
220
|
+
* await stateService.dispatchGetRoles();
|
|
221
|
+
* const roles = stateService.getRoles();
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare class IdentityStateService {
|
|
225
|
+
private identityService;
|
|
226
|
+
private roles;
|
|
227
|
+
private rolesTotalCount;
|
|
228
|
+
private users;
|
|
229
|
+
private usersTotalCount;
|
|
230
|
+
constructor(identityService: IdentityService);
|
|
231
|
+
/**
|
|
232
|
+
* Get the current roles from state
|
|
233
|
+
*/
|
|
234
|
+
getRoles(): Identity.RoleItem[];
|
|
235
|
+
/**
|
|
236
|
+
* Get the total count of roles
|
|
237
|
+
*/
|
|
238
|
+
getRolesTotalCount(): number;
|
|
239
|
+
/**
|
|
240
|
+
* Get the current users from state
|
|
241
|
+
*/
|
|
242
|
+
getUsers(): Identity.UserItem[];
|
|
243
|
+
/**
|
|
244
|
+
* Get the total count of users
|
|
245
|
+
*/
|
|
246
|
+
getUsersTotalCount(): number;
|
|
247
|
+
/**
|
|
248
|
+
* Fetch roles and update internal state
|
|
249
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
250
|
+
*/
|
|
251
|
+
dispatchGetRoles(params?: ABP.PageQueryParams): Promise<Identity.RoleResponse>;
|
|
252
|
+
/**
|
|
253
|
+
* Fetch a role by ID
|
|
254
|
+
* @param id - The role ID
|
|
255
|
+
*/
|
|
256
|
+
dispatchGetRoleById(id: string): Promise<Identity.RoleItem>;
|
|
257
|
+
/**
|
|
258
|
+
* Delete a role and refresh the list
|
|
259
|
+
* @param id - The role ID to delete
|
|
260
|
+
*/
|
|
261
|
+
dispatchDeleteRole(id: string): Promise<Identity.RoleItem>;
|
|
262
|
+
/**
|
|
263
|
+
* Create a new role and refresh the list
|
|
264
|
+
* @param body - The role data to create
|
|
265
|
+
*/
|
|
266
|
+
dispatchCreateRole(body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
|
|
267
|
+
/**
|
|
268
|
+
* Update an existing role and refresh the list
|
|
269
|
+
* @param payload - Object containing id and updated role data
|
|
270
|
+
*/
|
|
271
|
+
dispatchUpdateRole(payload: {
|
|
272
|
+
id: string;
|
|
273
|
+
body: Identity.RoleSaveRequest;
|
|
274
|
+
}): Promise<Identity.RoleItem>;
|
|
275
|
+
/**
|
|
276
|
+
* Fetch users and update internal state
|
|
277
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
278
|
+
*/
|
|
279
|
+
dispatchGetUsers(params?: ABP.PageQueryParams): Promise<Identity.UserResponse>;
|
|
280
|
+
/**
|
|
281
|
+
* Fetch a user by ID
|
|
282
|
+
* @param id - The user ID
|
|
283
|
+
*/
|
|
284
|
+
dispatchGetUserById(id: string): Promise<Identity.UserItem>;
|
|
285
|
+
/**
|
|
286
|
+
* Delete a user and refresh the list
|
|
287
|
+
* @param id - The user ID to delete
|
|
288
|
+
*/
|
|
289
|
+
dispatchDeleteUser(id: string): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Create a new user and refresh the list
|
|
292
|
+
* @param body - The user data to create
|
|
293
|
+
*/
|
|
294
|
+
dispatchCreateUser(body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
295
|
+
/**
|
|
296
|
+
* Update an existing user and refresh the list
|
|
297
|
+
* @param payload - Object containing id and updated user data
|
|
298
|
+
*/
|
|
299
|
+
dispatchUpdateUser(payload: {
|
|
300
|
+
id: string;
|
|
301
|
+
body: Identity.UserSaveRequest;
|
|
302
|
+
}): Promise<Identity.UserItem>;
|
|
303
|
+
/**
|
|
304
|
+
* Get roles assigned to a user
|
|
305
|
+
* @param id - The user ID
|
|
306
|
+
*/
|
|
307
|
+
dispatchGetUserRoles(id: string): Promise<Identity.RoleResponse>;
|
|
308
|
+
}
|
|
309
|
+
|
|
154
310
|
/**
|
|
155
311
|
* Result from role operations
|
|
156
312
|
*/
|
|
@@ -388,6 +544,11 @@ interface RolesComponentProps {
|
|
|
388
544
|
onRoleUpdated?: (role: Identity.RoleItem) => void;
|
|
389
545
|
/** Optional callback when a role is deleted */
|
|
390
546
|
onRoleDeleted?: (id: string) => void;
|
|
547
|
+
/**
|
|
548
|
+
* Callback when permission modal visibility changes
|
|
549
|
+
* @since 2.0.0
|
|
550
|
+
*/
|
|
551
|
+
onVisiblePermissionChange?: (visible: boolean) => void;
|
|
391
552
|
}
|
|
392
553
|
/**
|
|
393
554
|
* RolesComponent - Component for managing roles
|
|
@@ -407,8 +568,13 @@ interface RolesComponentProps {
|
|
|
407
568
|
* }
|
|
408
569
|
* ```
|
|
409
570
|
*/
|
|
410
|
-
declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, }: RolesComponentProps): React.ReactElement;
|
|
571
|
+
declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, onVisiblePermissionChange, }: RolesComponentProps): React.ReactElement;
|
|
411
572
|
|
|
573
|
+
/**
|
|
574
|
+
* Password rule type for validation display
|
|
575
|
+
* @since 1.1.0
|
|
576
|
+
*/
|
|
577
|
+
type PasswordRule = 'number' | 'small' | 'capital' | 'special';
|
|
412
578
|
/**
|
|
413
579
|
* Props for UsersComponent
|
|
414
580
|
*/
|
|
@@ -419,41 +585,24 @@ interface UsersComponentProps {
|
|
|
419
585
|
onUserUpdated?: (user: Identity.UserItem) => void;
|
|
420
586
|
/** Optional callback when a user is deleted */
|
|
421
587
|
onUserDeleted?: (id: string) => void;
|
|
588
|
+
/**
|
|
589
|
+
* Password validation rules to display
|
|
590
|
+
* @since 1.1.0
|
|
591
|
+
*/
|
|
592
|
+
passwordRulesArr?: PasswordRule[];
|
|
593
|
+
/**
|
|
594
|
+
* Required minimum password length
|
|
595
|
+
* @since 1.1.0
|
|
596
|
+
*/
|
|
597
|
+
requiredPasswordLength?: number;
|
|
598
|
+
/**
|
|
599
|
+
* Callback when permission modal visibility changes
|
|
600
|
+
* @since 2.0.0
|
|
601
|
+
*/
|
|
602
|
+
onVisiblePermissionChange?: (visible: boolean) => void;
|
|
422
603
|
}
|
|
423
|
-
|
|
424
|
-
* UsersComponent - Component for managing users
|
|
425
|
-
*
|
|
426
|
-
* This is the React equivalent of Angular's UsersComponent.
|
|
427
|
-
* It displays a table of users with CRUD operations, role assignment, and permission management.
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```tsx
|
|
431
|
-
* function IdentityPage() {
|
|
432
|
-
* return (
|
|
433
|
-
* <UsersComponent
|
|
434
|
-
* onUserCreated={(user) => console.log('User created:', user)}
|
|
435
|
-
* onUserDeleted={(id) => console.log('User deleted:', id)}
|
|
436
|
-
* />
|
|
437
|
-
* );
|
|
438
|
-
* }
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, }: UsersComponentProps): React.ReactElement;
|
|
604
|
+
declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, onVisiblePermissionChange, }: UsersComponentProps): React.ReactElement;
|
|
442
605
|
|
|
443
|
-
/**
|
|
444
|
-
* Identity module routes configuration.
|
|
445
|
-
* Translated from @abp/ng.identity IDENTITY_ROUTES.
|
|
446
|
-
*
|
|
447
|
-
* These routes define the navigation structure for the identity module
|
|
448
|
-
* within the ABP Framework application.
|
|
449
|
-
*
|
|
450
|
-
* @deprecated since version 1.0.0. Route configuration is now handled by
|
|
451
|
-
* identity config services. This constant is kept for backwards compatibility
|
|
452
|
-
* but may be removed in future versions.
|
|
453
|
-
*/
|
|
454
|
-
declare const IDENTITY_ROUTES: {
|
|
455
|
-
routes: ABP.FullRoute[];
|
|
456
|
-
};
|
|
457
606
|
/**
|
|
458
607
|
* Route paths for the identity module.
|
|
459
608
|
* Use these constants for programmatic navigation.
|
|
@@ -488,4 +637,4 @@ declare const IDENTITY_POLICIES: {
|
|
|
488
637
|
readonly ROLES_DELETE: "AbpIdentity.Roles.Delete";
|
|
489
638
|
};
|
|
490
639
|
|
|
491
|
-
export { IDENTITY_POLICIES,
|
|
640
|
+
export { IDENTITY_POLICIES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, IdentityStateService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,50 @@ declare namespace Identity {
|
|
|
70
70
|
password: string;
|
|
71
71
|
roleNames: string[];
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Input props for RolesComponent
|
|
75
|
+
* @since 2.0.0
|
|
76
|
+
*/
|
|
77
|
+
interface RolesComponentInputs {
|
|
78
|
+
/** Callback when a role is created */
|
|
79
|
+
readonly onRoleCreated?: (role: RoleItem) => void;
|
|
80
|
+
/** Callback when a role is updated */
|
|
81
|
+
readonly onRoleUpdated?: (role: RoleItem) => void;
|
|
82
|
+
/** Callback when a role is deleted */
|
|
83
|
+
readonly onRoleDeleted?: (id: string) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Output callbacks for RolesComponent
|
|
87
|
+
* @since 2.0.0
|
|
88
|
+
*/
|
|
89
|
+
interface RolesComponentOutputs {
|
|
90
|
+
/** Callback when permission modal visibility changes */
|
|
91
|
+
readonly onVisiblePermissionChange?: (visible: boolean) => void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Input props for UsersComponent
|
|
95
|
+
* @since 2.0.0
|
|
96
|
+
*/
|
|
97
|
+
interface UsersComponentInputs {
|
|
98
|
+
/** Callback when a user is created */
|
|
99
|
+
readonly onUserCreated?: (user: UserItem) => void;
|
|
100
|
+
/** Callback when a user is updated */
|
|
101
|
+
readonly onUserUpdated?: (user: UserItem) => void;
|
|
102
|
+
/** Callback when a user is deleted */
|
|
103
|
+
readonly onUserDeleted?: (id: string) => void;
|
|
104
|
+
/** Password validation rules to display */
|
|
105
|
+
readonly passwordRulesArr?: ('number' | 'small' | 'capital' | 'special')[];
|
|
106
|
+
/** Required minimum password length */
|
|
107
|
+
readonly requiredPasswordLength?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Output callbacks for UsersComponent
|
|
111
|
+
* @since 2.0.0
|
|
112
|
+
*/
|
|
113
|
+
interface UsersComponentOutputs {
|
|
114
|
+
/** Callback when permission modal visibility changes */
|
|
115
|
+
readonly onVisiblePermissionChange?: (visible: boolean) => void;
|
|
116
|
+
}
|
|
73
117
|
}
|
|
74
118
|
|
|
75
119
|
/**
|
|
@@ -151,6 +195,118 @@ declare class IdentityService {
|
|
|
151
195
|
updateUser(id: string, body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
152
196
|
}
|
|
153
197
|
|
|
198
|
+
/**
|
|
199
|
+
* IdentityStateService - A stateful service facade for identity operations.
|
|
200
|
+
*
|
|
201
|
+
* This service provides a stateful wrapper around IdentityService, maintaining
|
|
202
|
+
* local state for roles and users. It's the React equivalent of Angular's
|
|
203
|
+
* IdentityStateService which wraps NGXS store operations.
|
|
204
|
+
*
|
|
205
|
+
* For most React use cases, prefer using the hooks (useRoles, useUsers, useIdentity)
|
|
206
|
+
* instead of this class. This class is provided for programmatic/non-hook scenarios.
|
|
207
|
+
*
|
|
208
|
+
* @since 2.0.0
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { IdentityStateService, IdentityService } from '@abpjs/identity';
|
|
213
|
+
* import { RestService } from '@abpjs/core';
|
|
214
|
+
*
|
|
215
|
+
* const rest = new RestService();
|
|
216
|
+
* const identityService = new IdentityService(rest);
|
|
217
|
+
* const stateService = new IdentityStateService(identityService);
|
|
218
|
+
*
|
|
219
|
+
* // Fetch and get roles
|
|
220
|
+
* await stateService.dispatchGetRoles();
|
|
221
|
+
* const roles = stateService.getRoles();
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare class IdentityStateService {
|
|
225
|
+
private identityService;
|
|
226
|
+
private roles;
|
|
227
|
+
private rolesTotalCount;
|
|
228
|
+
private users;
|
|
229
|
+
private usersTotalCount;
|
|
230
|
+
constructor(identityService: IdentityService);
|
|
231
|
+
/**
|
|
232
|
+
* Get the current roles from state
|
|
233
|
+
*/
|
|
234
|
+
getRoles(): Identity.RoleItem[];
|
|
235
|
+
/**
|
|
236
|
+
* Get the total count of roles
|
|
237
|
+
*/
|
|
238
|
+
getRolesTotalCount(): number;
|
|
239
|
+
/**
|
|
240
|
+
* Get the current users from state
|
|
241
|
+
*/
|
|
242
|
+
getUsers(): Identity.UserItem[];
|
|
243
|
+
/**
|
|
244
|
+
* Get the total count of users
|
|
245
|
+
*/
|
|
246
|
+
getUsersTotalCount(): number;
|
|
247
|
+
/**
|
|
248
|
+
* Fetch roles and update internal state
|
|
249
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
250
|
+
*/
|
|
251
|
+
dispatchGetRoles(params?: ABP.PageQueryParams): Promise<Identity.RoleResponse>;
|
|
252
|
+
/**
|
|
253
|
+
* Fetch a role by ID
|
|
254
|
+
* @param id - The role ID
|
|
255
|
+
*/
|
|
256
|
+
dispatchGetRoleById(id: string): Promise<Identity.RoleItem>;
|
|
257
|
+
/**
|
|
258
|
+
* Delete a role and refresh the list
|
|
259
|
+
* @param id - The role ID to delete
|
|
260
|
+
*/
|
|
261
|
+
dispatchDeleteRole(id: string): Promise<Identity.RoleItem>;
|
|
262
|
+
/**
|
|
263
|
+
* Create a new role and refresh the list
|
|
264
|
+
* @param body - The role data to create
|
|
265
|
+
*/
|
|
266
|
+
dispatchCreateRole(body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
|
|
267
|
+
/**
|
|
268
|
+
* Update an existing role and refresh the list
|
|
269
|
+
* @param payload - Object containing id and updated role data
|
|
270
|
+
*/
|
|
271
|
+
dispatchUpdateRole(payload: {
|
|
272
|
+
id: string;
|
|
273
|
+
body: Identity.RoleSaveRequest;
|
|
274
|
+
}): Promise<Identity.RoleItem>;
|
|
275
|
+
/**
|
|
276
|
+
* Fetch users and update internal state
|
|
277
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
278
|
+
*/
|
|
279
|
+
dispatchGetUsers(params?: ABP.PageQueryParams): Promise<Identity.UserResponse>;
|
|
280
|
+
/**
|
|
281
|
+
* Fetch a user by ID
|
|
282
|
+
* @param id - The user ID
|
|
283
|
+
*/
|
|
284
|
+
dispatchGetUserById(id: string): Promise<Identity.UserItem>;
|
|
285
|
+
/**
|
|
286
|
+
* Delete a user and refresh the list
|
|
287
|
+
* @param id - The user ID to delete
|
|
288
|
+
*/
|
|
289
|
+
dispatchDeleteUser(id: string): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Create a new user and refresh the list
|
|
292
|
+
* @param body - The user data to create
|
|
293
|
+
*/
|
|
294
|
+
dispatchCreateUser(body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
295
|
+
/**
|
|
296
|
+
* Update an existing user and refresh the list
|
|
297
|
+
* @param payload - Object containing id and updated user data
|
|
298
|
+
*/
|
|
299
|
+
dispatchUpdateUser(payload: {
|
|
300
|
+
id: string;
|
|
301
|
+
body: Identity.UserSaveRequest;
|
|
302
|
+
}): Promise<Identity.UserItem>;
|
|
303
|
+
/**
|
|
304
|
+
* Get roles assigned to a user
|
|
305
|
+
* @param id - The user ID
|
|
306
|
+
*/
|
|
307
|
+
dispatchGetUserRoles(id: string): Promise<Identity.RoleResponse>;
|
|
308
|
+
}
|
|
309
|
+
|
|
154
310
|
/**
|
|
155
311
|
* Result from role operations
|
|
156
312
|
*/
|
|
@@ -388,6 +544,11 @@ interface RolesComponentProps {
|
|
|
388
544
|
onRoleUpdated?: (role: Identity.RoleItem) => void;
|
|
389
545
|
/** Optional callback when a role is deleted */
|
|
390
546
|
onRoleDeleted?: (id: string) => void;
|
|
547
|
+
/**
|
|
548
|
+
* Callback when permission modal visibility changes
|
|
549
|
+
* @since 2.0.0
|
|
550
|
+
*/
|
|
551
|
+
onVisiblePermissionChange?: (visible: boolean) => void;
|
|
391
552
|
}
|
|
392
553
|
/**
|
|
393
554
|
* RolesComponent - Component for managing roles
|
|
@@ -407,8 +568,13 @@ interface RolesComponentProps {
|
|
|
407
568
|
* }
|
|
408
569
|
* ```
|
|
409
570
|
*/
|
|
410
|
-
declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, }: RolesComponentProps): React.ReactElement;
|
|
571
|
+
declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, onVisiblePermissionChange, }: RolesComponentProps): React.ReactElement;
|
|
411
572
|
|
|
573
|
+
/**
|
|
574
|
+
* Password rule type for validation display
|
|
575
|
+
* @since 1.1.0
|
|
576
|
+
*/
|
|
577
|
+
type PasswordRule = 'number' | 'small' | 'capital' | 'special';
|
|
412
578
|
/**
|
|
413
579
|
* Props for UsersComponent
|
|
414
580
|
*/
|
|
@@ -419,41 +585,24 @@ interface UsersComponentProps {
|
|
|
419
585
|
onUserUpdated?: (user: Identity.UserItem) => void;
|
|
420
586
|
/** Optional callback when a user is deleted */
|
|
421
587
|
onUserDeleted?: (id: string) => void;
|
|
588
|
+
/**
|
|
589
|
+
* Password validation rules to display
|
|
590
|
+
* @since 1.1.0
|
|
591
|
+
*/
|
|
592
|
+
passwordRulesArr?: PasswordRule[];
|
|
593
|
+
/**
|
|
594
|
+
* Required minimum password length
|
|
595
|
+
* @since 1.1.0
|
|
596
|
+
*/
|
|
597
|
+
requiredPasswordLength?: number;
|
|
598
|
+
/**
|
|
599
|
+
* Callback when permission modal visibility changes
|
|
600
|
+
* @since 2.0.0
|
|
601
|
+
*/
|
|
602
|
+
onVisiblePermissionChange?: (visible: boolean) => void;
|
|
422
603
|
}
|
|
423
|
-
|
|
424
|
-
* UsersComponent - Component for managing users
|
|
425
|
-
*
|
|
426
|
-
* This is the React equivalent of Angular's UsersComponent.
|
|
427
|
-
* It displays a table of users with CRUD operations, role assignment, and permission management.
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```tsx
|
|
431
|
-
* function IdentityPage() {
|
|
432
|
-
* return (
|
|
433
|
-
* <UsersComponent
|
|
434
|
-
* onUserCreated={(user) => console.log('User created:', user)}
|
|
435
|
-
* onUserDeleted={(id) => console.log('User deleted:', id)}
|
|
436
|
-
* />
|
|
437
|
-
* );
|
|
438
|
-
* }
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, }: UsersComponentProps): React.ReactElement;
|
|
604
|
+
declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, onVisiblePermissionChange, }: UsersComponentProps): React.ReactElement;
|
|
442
605
|
|
|
443
|
-
/**
|
|
444
|
-
* Identity module routes configuration.
|
|
445
|
-
* Translated from @abp/ng.identity IDENTITY_ROUTES.
|
|
446
|
-
*
|
|
447
|
-
* These routes define the navigation structure for the identity module
|
|
448
|
-
* within the ABP Framework application.
|
|
449
|
-
*
|
|
450
|
-
* @deprecated since version 1.0.0. Route configuration is now handled by
|
|
451
|
-
* identity config services. This constant is kept for backwards compatibility
|
|
452
|
-
* but may be removed in future versions.
|
|
453
|
-
*/
|
|
454
|
-
declare const IDENTITY_ROUTES: {
|
|
455
|
-
routes: ABP.FullRoute[];
|
|
456
|
-
};
|
|
457
606
|
/**
|
|
458
607
|
* Route paths for the identity module.
|
|
459
608
|
* Use these constants for programmatic navigation.
|
|
@@ -488,4 +637,4 @@ declare const IDENTITY_POLICIES: {
|
|
|
488
637
|
readonly ROLES_DELETE: "AbpIdentity.Roles.Delete";
|
|
489
638
|
};
|
|
490
639
|
|
|
491
|
-
export { IDENTITY_POLICIES,
|
|
640
|
+
export { IDENTITY_POLICIES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, IdentityStateService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
|
package/dist/index.js
CHANGED
|
@@ -21,9 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
IDENTITY_POLICIES: () => IDENTITY_POLICIES,
|
|
24
|
-
IDENTITY_ROUTES: () => IDENTITY_ROUTES,
|
|
25
24
|
IDENTITY_ROUTE_PATHS: () => IDENTITY_ROUTE_PATHS,
|
|
26
25
|
IdentityService: () => IdentityService,
|
|
26
|
+
IdentityStateService: () => IdentityStateService,
|
|
27
27
|
RolesComponent: () => RolesComponent,
|
|
28
28
|
UsersComponent: () => UsersComponent,
|
|
29
29
|
useIdentity: () => useIdentity,
|
|
@@ -174,6 +174,145 @@ var IdentityService = class {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
+
// src/services/identity-state.service.ts
|
|
178
|
+
var IdentityStateService = class {
|
|
179
|
+
constructor(identityService) {
|
|
180
|
+
// Internal state
|
|
181
|
+
this.roles = [];
|
|
182
|
+
this.rolesTotalCount = 0;
|
|
183
|
+
this.users = [];
|
|
184
|
+
this.usersTotalCount = 0;
|
|
185
|
+
this.identityService = identityService;
|
|
186
|
+
}
|
|
187
|
+
// ========================
|
|
188
|
+
// State Getters
|
|
189
|
+
// ========================
|
|
190
|
+
/**
|
|
191
|
+
* Get the current roles from state
|
|
192
|
+
*/
|
|
193
|
+
getRoles() {
|
|
194
|
+
return this.roles;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the total count of roles
|
|
198
|
+
*/
|
|
199
|
+
getRolesTotalCount() {
|
|
200
|
+
return this.rolesTotalCount;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get the current users from state
|
|
204
|
+
*/
|
|
205
|
+
getUsers() {
|
|
206
|
+
return this.users;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get the total count of users
|
|
210
|
+
*/
|
|
211
|
+
getUsersTotalCount() {
|
|
212
|
+
return this.usersTotalCount;
|
|
213
|
+
}
|
|
214
|
+
// ========================
|
|
215
|
+
// Role Dispatch Methods
|
|
216
|
+
// ========================
|
|
217
|
+
/**
|
|
218
|
+
* Fetch roles and update internal state
|
|
219
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
220
|
+
*/
|
|
221
|
+
async dispatchGetRoles(params) {
|
|
222
|
+
const response = await this.identityService.getRoles(params);
|
|
223
|
+
this.roles = response.items;
|
|
224
|
+
this.rolesTotalCount = response.totalCount;
|
|
225
|
+
return response;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Fetch a role by ID
|
|
229
|
+
* @param id - The role ID
|
|
230
|
+
*/
|
|
231
|
+
async dispatchGetRoleById(id) {
|
|
232
|
+
return this.identityService.getRoleById(id);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Delete a role and refresh the list
|
|
236
|
+
* @param id - The role ID to delete
|
|
237
|
+
*/
|
|
238
|
+
async dispatchDeleteRole(id) {
|
|
239
|
+
const result = await this.identityService.deleteRole(id);
|
|
240
|
+
await this.dispatchGetRoles();
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create a new role and refresh the list
|
|
245
|
+
* @param body - The role data to create
|
|
246
|
+
*/
|
|
247
|
+
async dispatchCreateRole(body) {
|
|
248
|
+
const result = await this.identityService.createRole(body);
|
|
249
|
+
await this.dispatchGetRoles();
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Update an existing role and refresh the list
|
|
254
|
+
* @param payload - Object containing id and updated role data
|
|
255
|
+
*/
|
|
256
|
+
async dispatchUpdateRole(payload) {
|
|
257
|
+
const result = await this.identityService.updateRole(payload.id, payload.body);
|
|
258
|
+
await this.dispatchGetRoles();
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
// ========================
|
|
262
|
+
// User Dispatch Methods
|
|
263
|
+
// ========================
|
|
264
|
+
/**
|
|
265
|
+
* Fetch users and update internal state
|
|
266
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
267
|
+
*/
|
|
268
|
+
async dispatchGetUsers(params) {
|
|
269
|
+
const response = await this.identityService.getUsers(params);
|
|
270
|
+
this.users = response.items;
|
|
271
|
+
this.usersTotalCount = response.totalCount;
|
|
272
|
+
return response;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Fetch a user by ID
|
|
276
|
+
* @param id - The user ID
|
|
277
|
+
*/
|
|
278
|
+
async dispatchGetUserById(id) {
|
|
279
|
+
return this.identityService.getUserById(id);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Delete a user and refresh the list
|
|
283
|
+
* @param id - The user ID to delete
|
|
284
|
+
*/
|
|
285
|
+
async dispatchDeleteUser(id) {
|
|
286
|
+
await this.identityService.deleteUser(id);
|
|
287
|
+
await this.dispatchGetUsers();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Create a new user and refresh the list
|
|
291
|
+
* @param body - The user data to create
|
|
292
|
+
*/
|
|
293
|
+
async dispatchCreateUser(body) {
|
|
294
|
+
const result = await this.identityService.createUser(body);
|
|
295
|
+
await this.dispatchGetUsers();
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Update an existing user and refresh the list
|
|
300
|
+
* @param payload - Object containing id and updated user data
|
|
301
|
+
*/
|
|
302
|
+
async dispatchUpdateUser(payload) {
|
|
303
|
+
const result = await this.identityService.updateUser(payload.id, payload.body);
|
|
304
|
+
await this.dispatchGetUsers();
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get roles assigned to a user
|
|
309
|
+
* @param id - The user ID
|
|
310
|
+
*/
|
|
311
|
+
async dispatchGetUserRoles(id) {
|
|
312
|
+
return this.identityService.getUserRoles(id);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
177
316
|
// src/hooks/useRoles.ts
|
|
178
317
|
var import_react = require("react");
|
|
179
318
|
var import_core = require("@abpjs/core");
|
|
@@ -500,7 +639,8 @@ var DEFAULT_FORM_STATE = {
|
|
|
500
639
|
function RolesComponent({
|
|
501
640
|
onRoleCreated,
|
|
502
641
|
onRoleUpdated,
|
|
503
|
-
onRoleDeleted
|
|
642
|
+
onRoleDeleted,
|
|
643
|
+
onVisiblePermissionChange
|
|
504
644
|
}) {
|
|
505
645
|
const { t } = (0, import_core3.useLocalization)();
|
|
506
646
|
const confirmation = (0, import_theme_shared.useConfirmation)();
|
|
@@ -707,7 +847,10 @@ function RolesComponent({
|
|
|
707
847
|
import_permission_management.PermissionManagementModal,
|
|
708
848
|
{
|
|
709
849
|
visible: isPermissionModalOpen,
|
|
710
|
-
onVisibleChange:
|
|
850
|
+
onVisibleChange: (visible) => {
|
|
851
|
+
setIsPermissionModalOpen(visible);
|
|
852
|
+
onVisiblePermissionChange?.(visible);
|
|
853
|
+
},
|
|
711
854
|
providerName: "R",
|
|
712
855
|
providerKey: permissionProviderKey
|
|
713
856
|
}
|
|
@@ -733,10 +876,27 @@ var DEFAULT_FORM_STATE2 = {
|
|
|
733
876
|
twoFactorEnabled: true,
|
|
734
877
|
roleNames: []
|
|
735
878
|
};
|
|
879
|
+
function getPasswordRuleLabel(rule, t) {
|
|
880
|
+
switch (rule) {
|
|
881
|
+
case "number":
|
|
882
|
+
return t("AbpIdentity::Password:RequireDigit");
|
|
883
|
+
case "small":
|
|
884
|
+
return t("AbpIdentity::Password:RequireLowercase");
|
|
885
|
+
case "capital":
|
|
886
|
+
return t("AbpIdentity::Password:RequireUppercase");
|
|
887
|
+
case "special":
|
|
888
|
+
return t("AbpIdentity::Password:RequireNonAlphanumeric");
|
|
889
|
+
default:
|
|
890
|
+
return rule;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
736
893
|
function UsersComponent({
|
|
737
894
|
onUserCreated,
|
|
738
895
|
onUserUpdated,
|
|
739
|
-
onUserDeleted
|
|
896
|
+
onUserDeleted,
|
|
897
|
+
passwordRulesArr = [],
|
|
898
|
+
requiredPasswordLength = 0,
|
|
899
|
+
onVisiblePermissionChange
|
|
740
900
|
}) {
|
|
741
901
|
const { t } = (0, import_core4.useLocalization)();
|
|
742
902
|
const confirmation = (0, import_theme_shared2.useConfirmation)();
|
|
@@ -1032,17 +1192,26 @@ function UsersComponent({
|
|
|
1032
1192
|
}
|
|
1033
1193
|
) })
|
|
1034
1194
|
] }),
|
|
1035
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1195
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_theme_shared2.FormField, { label: t("AbpIdentity::Password"), required: !selectedUser?.id, children: [
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1197
|
+
import_react7.Input,
|
|
1198
|
+
{
|
|
1199
|
+
type: "password",
|
|
1200
|
+
value: formState.password,
|
|
1201
|
+
onChange: (e) => handleInputChange("password", e.target.value),
|
|
1202
|
+
autoComplete: "new-password",
|
|
1203
|
+
maxLength: 32,
|
|
1204
|
+
placeholder: selectedUser?.id ? t("AbpIdentity::LeaveBlankToKeepCurrent") : ""
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1207
|
+
(requiredPasswordLength > 0 || passwordRulesArr.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react7.Box, { mt: 2, fontSize: "sm", color: "gray.500", children: [
|
|
1208
|
+
requiredPasswordLength > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react7.Text, { children: t("AbpIdentity::Password:MinLength", String(requiredPasswordLength)) }),
|
|
1209
|
+
passwordRulesArr.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react7.Text, { children: [
|
|
1210
|
+
"\u2022 ",
|
|
1211
|
+
getPasswordRuleLabel(rule, t)
|
|
1212
|
+
] }, rule))
|
|
1213
|
+
] })
|
|
1214
|
+
] }),
|
|
1046
1215
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_theme_shared2.FormField, { label: t("AbpIdentity::EmailAddress"), required: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1047
1216
|
import_react7.Input,
|
|
1048
1217
|
{
|
|
@@ -1096,7 +1265,10 @@ function UsersComponent({
|
|
|
1096
1265
|
import_permission_management2.PermissionManagementModal,
|
|
1097
1266
|
{
|
|
1098
1267
|
visible: isPermissionModalOpen,
|
|
1099
|
-
onVisibleChange:
|
|
1268
|
+
onVisibleChange: (visible) => {
|
|
1269
|
+
setIsPermissionModalOpen(visible);
|
|
1270
|
+
onVisiblePermissionChange?.(visible);
|
|
1271
|
+
},
|
|
1100
1272
|
providerName: "U",
|
|
1101
1273
|
providerKey: permissionProviderKey
|
|
1102
1274
|
}
|
|
@@ -1105,38 +1277,6 @@ function UsersComponent({
|
|
|
1105
1277
|
}
|
|
1106
1278
|
|
|
1107
1279
|
// src/constants/routes.ts
|
|
1108
|
-
var import_core5 = require("@abpjs/core");
|
|
1109
|
-
var IDENTITY_ROUTES = {
|
|
1110
|
-
routes: [
|
|
1111
|
-
{
|
|
1112
|
-
name: "AbpUiNavigation::Menu:Administration",
|
|
1113
|
-
path: "",
|
|
1114
|
-
order: 1,
|
|
1115
|
-
wrapper: true
|
|
1116
|
-
},
|
|
1117
|
-
{
|
|
1118
|
-
name: "AbpIdentity::Menu:IdentityManagement",
|
|
1119
|
-
path: "identity",
|
|
1120
|
-
order: 1,
|
|
1121
|
-
parentName: "AbpUiNavigation::Menu:Administration",
|
|
1122
|
-
layout: import_core5.eLayoutType.application,
|
|
1123
|
-
children: [
|
|
1124
|
-
{
|
|
1125
|
-
path: "roles",
|
|
1126
|
-
name: "AbpIdentity::Roles",
|
|
1127
|
-
order: 2,
|
|
1128
|
-
requiredPolicy: "AbpIdentity.Roles"
|
|
1129
|
-
},
|
|
1130
|
-
{
|
|
1131
|
-
path: "users",
|
|
1132
|
-
name: "AbpIdentity::Users",
|
|
1133
|
-
order: 1,
|
|
1134
|
-
requiredPolicy: "AbpIdentity.Users"
|
|
1135
|
-
}
|
|
1136
|
-
]
|
|
1137
|
-
}
|
|
1138
|
-
]
|
|
1139
|
-
};
|
|
1140
1280
|
var IDENTITY_ROUTE_PATHS = {
|
|
1141
1281
|
/** Base path for identity module */
|
|
1142
1282
|
BASE: "/identity",
|
|
@@ -1166,9 +1306,9 @@ var IDENTITY_POLICIES = {
|
|
|
1166
1306
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1167
1307
|
0 && (module.exports = {
|
|
1168
1308
|
IDENTITY_POLICIES,
|
|
1169
|
-
IDENTITY_ROUTES,
|
|
1170
1309
|
IDENTITY_ROUTE_PATHS,
|
|
1171
1310
|
IdentityService,
|
|
1311
|
+
IdentityStateService,
|
|
1172
1312
|
RolesComponent,
|
|
1173
1313
|
UsersComponent,
|
|
1174
1314
|
useIdentity,
|
package/dist/index.mjs
CHANGED
|
@@ -140,6 +140,145 @@ var IdentityService = class {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
// src/services/identity-state.service.ts
|
|
144
|
+
var IdentityStateService = class {
|
|
145
|
+
constructor(identityService) {
|
|
146
|
+
// Internal state
|
|
147
|
+
this.roles = [];
|
|
148
|
+
this.rolesTotalCount = 0;
|
|
149
|
+
this.users = [];
|
|
150
|
+
this.usersTotalCount = 0;
|
|
151
|
+
this.identityService = identityService;
|
|
152
|
+
}
|
|
153
|
+
// ========================
|
|
154
|
+
// State Getters
|
|
155
|
+
// ========================
|
|
156
|
+
/**
|
|
157
|
+
* Get the current roles from state
|
|
158
|
+
*/
|
|
159
|
+
getRoles() {
|
|
160
|
+
return this.roles;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get the total count of roles
|
|
164
|
+
*/
|
|
165
|
+
getRolesTotalCount() {
|
|
166
|
+
return this.rolesTotalCount;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the current users from state
|
|
170
|
+
*/
|
|
171
|
+
getUsers() {
|
|
172
|
+
return this.users;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the total count of users
|
|
176
|
+
*/
|
|
177
|
+
getUsersTotalCount() {
|
|
178
|
+
return this.usersTotalCount;
|
|
179
|
+
}
|
|
180
|
+
// ========================
|
|
181
|
+
// Role Dispatch Methods
|
|
182
|
+
// ========================
|
|
183
|
+
/**
|
|
184
|
+
* Fetch roles and update internal state
|
|
185
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
186
|
+
*/
|
|
187
|
+
async dispatchGetRoles(params) {
|
|
188
|
+
const response = await this.identityService.getRoles(params);
|
|
189
|
+
this.roles = response.items;
|
|
190
|
+
this.rolesTotalCount = response.totalCount;
|
|
191
|
+
return response;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Fetch a role by ID
|
|
195
|
+
* @param id - The role ID
|
|
196
|
+
*/
|
|
197
|
+
async dispatchGetRoleById(id) {
|
|
198
|
+
return this.identityService.getRoleById(id);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Delete a role and refresh the list
|
|
202
|
+
* @param id - The role ID to delete
|
|
203
|
+
*/
|
|
204
|
+
async dispatchDeleteRole(id) {
|
|
205
|
+
const result = await this.identityService.deleteRole(id);
|
|
206
|
+
await this.dispatchGetRoles();
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a new role and refresh the list
|
|
211
|
+
* @param body - The role data to create
|
|
212
|
+
*/
|
|
213
|
+
async dispatchCreateRole(body) {
|
|
214
|
+
const result = await this.identityService.createRole(body);
|
|
215
|
+
await this.dispatchGetRoles();
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Update an existing role and refresh the list
|
|
220
|
+
* @param payload - Object containing id and updated role data
|
|
221
|
+
*/
|
|
222
|
+
async dispatchUpdateRole(payload) {
|
|
223
|
+
const result = await this.identityService.updateRole(payload.id, payload.body);
|
|
224
|
+
await this.dispatchGetRoles();
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
// ========================
|
|
228
|
+
// User Dispatch Methods
|
|
229
|
+
// ========================
|
|
230
|
+
/**
|
|
231
|
+
* Fetch users and update internal state
|
|
232
|
+
* @param params - Optional query parameters for pagination/filtering
|
|
233
|
+
*/
|
|
234
|
+
async dispatchGetUsers(params) {
|
|
235
|
+
const response = await this.identityService.getUsers(params);
|
|
236
|
+
this.users = response.items;
|
|
237
|
+
this.usersTotalCount = response.totalCount;
|
|
238
|
+
return response;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Fetch a user by ID
|
|
242
|
+
* @param id - The user ID
|
|
243
|
+
*/
|
|
244
|
+
async dispatchGetUserById(id) {
|
|
245
|
+
return this.identityService.getUserById(id);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Delete a user and refresh the list
|
|
249
|
+
* @param id - The user ID to delete
|
|
250
|
+
*/
|
|
251
|
+
async dispatchDeleteUser(id) {
|
|
252
|
+
await this.identityService.deleteUser(id);
|
|
253
|
+
await this.dispatchGetUsers();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create a new user and refresh the list
|
|
257
|
+
* @param body - The user data to create
|
|
258
|
+
*/
|
|
259
|
+
async dispatchCreateUser(body) {
|
|
260
|
+
const result = await this.identityService.createUser(body);
|
|
261
|
+
await this.dispatchGetUsers();
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Update an existing user and refresh the list
|
|
266
|
+
* @param payload - Object containing id and updated user data
|
|
267
|
+
*/
|
|
268
|
+
async dispatchUpdateUser(payload) {
|
|
269
|
+
const result = await this.identityService.updateUser(payload.id, payload.body);
|
|
270
|
+
await this.dispatchGetUsers();
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get roles assigned to a user
|
|
275
|
+
* @param id - The user ID
|
|
276
|
+
*/
|
|
277
|
+
async dispatchGetUserRoles(id) {
|
|
278
|
+
return this.identityService.getUserRoles(id);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
143
282
|
// src/hooks/useRoles.ts
|
|
144
283
|
import { useState, useCallback, useMemo } from "react";
|
|
145
284
|
import { useRestService } from "@abpjs/core";
|
|
@@ -475,7 +614,8 @@ var DEFAULT_FORM_STATE = {
|
|
|
475
614
|
function RolesComponent({
|
|
476
615
|
onRoleCreated,
|
|
477
616
|
onRoleUpdated,
|
|
478
|
-
onRoleDeleted
|
|
617
|
+
onRoleDeleted,
|
|
618
|
+
onVisiblePermissionChange
|
|
479
619
|
}) {
|
|
480
620
|
const { t } = useLocalization();
|
|
481
621
|
const confirmation = useConfirmation();
|
|
@@ -682,7 +822,10 @@ function RolesComponent({
|
|
|
682
822
|
PermissionManagementModal,
|
|
683
823
|
{
|
|
684
824
|
visible: isPermissionModalOpen,
|
|
685
|
-
onVisibleChange:
|
|
825
|
+
onVisibleChange: (visible) => {
|
|
826
|
+
setIsPermissionModalOpen(visible);
|
|
827
|
+
onVisiblePermissionChange?.(visible);
|
|
828
|
+
},
|
|
686
829
|
providerName: "R",
|
|
687
830
|
providerKey: permissionProviderKey
|
|
688
831
|
}
|
|
@@ -719,10 +862,27 @@ var DEFAULT_FORM_STATE2 = {
|
|
|
719
862
|
twoFactorEnabled: true,
|
|
720
863
|
roleNames: []
|
|
721
864
|
};
|
|
865
|
+
function getPasswordRuleLabel(rule, t) {
|
|
866
|
+
switch (rule) {
|
|
867
|
+
case "number":
|
|
868
|
+
return t("AbpIdentity::Password:RequireDigit");
|
|
869
|
+
case "small":
|
|
870
|
+
return t("AbpIdentity::Password:RequireLowercase");
|
|
871
|
+
case "capital":
|
|
872
|
+
return t("AbpIdentity::Password:RequireUppercase");
|
|
873
|
+
case "special":
|
|
874
|
+
return t("AbpIdentity::Password:RequireNonAlphanumeric");
|
|
875
|
+
default:
|
|
876
|
+
return rule;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
722
879
|
function UsersComponent({
|
|
723
880
|
onUserCreated,
|
|
724
881
|
onUserUpdated,
|
|
725
|
-
onUserDeleted
|
|
882
|
+
onUserDeleted,
|
|
883
|
+
passwordRulesArr = [],
|
|
884
|
+
requiredPasswordLength = 0,
|
|
885
|
+
onVisiblePermissionChange
|
|
726
886
|
}) {
|
|
727
887
|
const { t } = useLocalization2();
|
|
728
888
|
const confirmation = useConfirmation2();
|
|
@@ -1018,17 +1178,26 @@ function UsersComponent({
|
|
|
1018
1178
|
}
|
|
1019
1179
|
) })
|
|
1020
1180
|
] }),
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1181
|
+
/* @__PURE__ */ jsxs2(FormField2, { label: t("AbpIdentity::Password"), required: !selectedUser?.id, children: [
|
|
1182
|
+
/* @__PURE__ */ jsx2(
|
|
1183
|
+
Input2,
|
|
1184
|
+
{
|
|
1185
|
+
type: "password",
|
|
1186
|
+
value: formState.password,
|
|
1187
|
+
onChange: (e) => handleInputChange("password", e.target.value),
|
|
1188
|
+
autoComplete: "new-password",
|
|
1189
|
+
maxLength: 32,
|
|
1190
|
+
placeholder: selectedUser?.id ? t("AbpIdentity::LeaveBlankToKeepCurrent") : ""
|
|
1191
|
+
}
|
|
1192
|
+
),
|
|
1193
|
+
(requiredPasswordLength > 0 || passwordRulesArr.length > 0) && /* @__PURE__ */ jsxs2(Box2, { mt: 2, fontSize: "sm", color: "gray.500", children: [
|
|
1194
|
+
requiredPasswordLength > 0 && /* @__PURE__ */ jsx2(Text2, { children: t("AbpIdentity::Password:MinLength", String(requiredPasswordLength)) }),
|
|
1195
|
+
passwordRulesArr.map((rule) => /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
1196
|
+
"\u2022 ",
|
|
1197
|
+
getPasswordRuleLabel(rule, t)
|
|
1198
|
+
] }, rule))
|
|
1199
|
+
] })
|
|
1200
|
+
] }),
|
|
1032
1201
|
/* @__PURE__ */ jsx2(FormField2, { label: t("AbpIdentity::EmailAddress"), required: true, children: /* @__PURE__ */ jsx2(
|
|
1033
1202
|
Input2,
|
|
1034
1203
|
{
|
|
@@ -1082,7 +1251,10 @@ function UsersComponent({
|
|
|
1082
1251
|
PermissionManagementModal2,
|
|
1083
1252
|
{
|
|
1084
1253
|
visible: isPermissionModalOpen,
|
|
1085
|
-
onVisibleChange:
|
|
1254
|
+
onVisibleChange: (visible) => {
|
|
1255
|
+
setIsPermissionModalOpen(visible);
|
|
1256
|
+
onVisiblePermissionChange?.(visible);
|
|
1257
|
+
},
|
|
1086
1258
|
providerName: "U",
|
|
1087
1259
|
providerKey: permissionProviderKey
|
|
1088
1260
|
}
|
|
@@ -1091,38 +1263,6 @@ function UsersComponent({
|
|
|
1091
1263
|
}
|
|
1092
1264
|
|
|
1093
1265
|
// src/constants/routes.ts
|
|
1094
|
-
import { eLayoutType } from "@abpjs/core";
|
|
1095
|
-
var IDENTITY_ROUTES = {
|
|
1096
|
-
routes: [
|
|
1097
|
-
{
|
|
1098
|
-
name: "AbpUiNavigation::Menu:Administration",
|
|
1099
|
-
path: "",
|
|
1100
|
-
order: 1,
|
|
1101
|
-
wrapper: true
|
|
1102
|
-
},
|
|
1103
|
-
{
|
|
1104
|
-
name: "AbpIdentity::Menu:IdentityManagement",
|
|
1105
|
-
path: "identity",
|
|
1106
|
-
order: 1,
|
|
1107
|
-
parentName: "AbpUiNavigation::Menu:Administration",
|
|
1108
|
-
layout: eLayoutType.application,
|
|
1109
|
-
children: [
|
|
1110
|
-
{
|
|
1111
|
-
path: "roles",
|
|
1112
|
-
name: "AbpIdentity::Roles",
|
|
1113
|
-
order: 2,
|
|
1114
|
-
requiredPolicy: "AbpIdentity.Roles"
|
|
1115
|
-
},
|
|
1116
|
-
{
|
|
1117
|
-
path: "users",
|
|
1118
|
-
name: "AbpIdentity::Users",
|
|
1119
|
-
order: 1,
|
|
1120
|
-
requiredPolicy: "AbpIdentity.Users"
|
|
1121
|
-
}
|
|
1122
|
-
]
|
|
1123
|
-
}
|
|
1124
|
-
]
|
|
1125
|
-
};
|
|
1126
1266
|
var IDENTITY_ROUTE_PATHS = {
|
|
1127
1267
|
/** Base path for identity module */
|
|
1128
1268
|
BASE: "/identity",
|
|
@@ -1151,9 +1291,9 @@ var IDENTITY_POLICIES = {
|
|
|
1151
1291
|
};
|
|
1152
1292
|
export {
|
|
1153
1293
|
IDENTITY_POLICIES,
|
|
1154
|
-
IDENTITY_ROUTES,
|
|
1155
1294
|
IDENTITY_ROUTE_PATHS,
|
|
1156
1295
|
IdentityService,
|
|
1296
|
+
IdentityStateService,
|
|
1157
1297
|
RolesComponent,
|
|
1158
1298
|
UsersComponent,
|
|
1159
1299
|
useIdentity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/identity",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "ABP Framework identity components for React - translated from @abp/ng.identity",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@chakra-ui/react": "^3.2.0",
|
|
27
27
|
"@emotion/react": "^11.11.0",
|
|
28
|
-
"@abpjs/core": "
|
|
29
|
-
"@abpjs/
|
|
30
|
-
"@abpjs/
|
|
28
|
+
"@abpjs/core": "2.0.0",
|
|
29
|
+
"@abpjs/permission-management": "2.0.0",
|
|
30
|
+
"@abpjs/theme-shared": "2.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@abp/ng.identity": "0.
|
|
33
|
+
"@abp/ng.identity": "2.0.0",
|
|
34
34
|
"@testing-library/jest-dom": "^6.9.1",
|
|
35
35
|
"@testing-library/react": "^14.0.0",
|
|
36
36
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
},
|
|
63
63
|
"repository": {
|
|
64
64
|
"type": "git",
|
|
65
|
-
"url": "https://github.com/abpjs/abp-react"
|
|
65
|
+
"url": "https://github.com/abpjs/abp-react",
|
|
66
|
+
"directory": "packages/identity"
|
|
66
67
|
},
|
|
67
68
|
"homepage": "https://docs.abpjs.io/docs/packages/identity/overview",
|
|
68
69
|
"bugs": {
|