@abpjs/identity 3.1.0 → 4.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 +402 -166
- package/dist/index.d.ts +402 -166
- package/dist/index.js +358 -217
- package/dist/index.mjs +354 -216
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -33,9 +33,9 @@ var eIdentityRouteNames = {
|
|
|
33
33
|
|
|
34
34
|
// src/config/providers/route.provider.ts
|
|
35
35
|
import { getRoutesService, eLayoutType } from "@abpjs/core";
|
|
36
|
-
function configureRoutes(
|
|
36
|
+
function configureRoutes(routesService) {
|
|
37
37
|
return () => {
|
|
38
|
-
|
|
38
|
+
routesService.add([
|
|
39
39
|
{
|
|
40
40
|
path: "/identity",
|
|
41
41
|
name: eIdentityRouteNames.IdentityManagement,
|
|
@@ -66,8 +66,8 @@ var IDENTITY_ROUTE_PROVIDERS = {
|
|
|
66
66
|
configureRoutes
|
|
67
67
|
};
|
|
68
68
|
function initializeIdentityRoutes() {
|
|
69
|
-
const
|
|
70
|
-
const addRoutes = configureRoutes(
|
|
69
|
+
const routesService = getRoutesService();
|
|
70
|
+
const addRoutes = configureRoutes(routesService);
|
|
71
71
|
addRoutes();
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -85,192 +85,331 @@ var eIdentityComponents = {
|
|
|
85
85
|
Users: "Identity.UsersComponent"
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
// src/
|
|
89
|
-
var
|
|
90
|
-
constructor(
|
|
88
|
+
// src/proxy/identity/identity-role.service.ts
|
|
89
|
+
var IdentityRoleService = class {
|
|
90
|
+
constructor(restService) {
|
|
91
91
|
/**
|
|
92
92
|
* The API name used for REST requests.
|
|
93
|
-
* @since 2.4.0
|
|
94
93
|
*/
|
|
95
94
|
this.apiName = "default";
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return this.rest.request({
|
|
167
|
-
method: "PUT",
|
|
168
|
-
url: `/api/identity/roles/${id}`,
|
|
169
|
-
body
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
// ========================
|
|
173
|
-
// User Operations
|
|
174
|
-
// ========================
|
|
175
|
-
/**
|
|
176
|
-
* Get users with pagination and filtering
|
|
177
|
-
* @param params - Query parameters for pagination and filtering
|
|
178
|
-
* @returns Promise with paginated user response
|
|
179
|
-
*/
|
|
180
|
-
getUsers(params = {}) {
|
|
181
|
-
return this.rest.request({
|
|
182
|
-
method: "GET",
|
|
183
|
-
url: "/api/identity/users",
|
|
184
|
-
params
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Get a user by ID
|
|
189
|
-
* @param id - The user ID
|
|
190
|
-
* @returns Promise with the user item
|
|
191
|
-
*/
|
|
192
|
-
getUserById(id) {
|
|
193
|
-
return this.rest.request({
|
|
194
|
-
method: "GET",
|
|
195
|
-
url: `/api/identity/users/${id}`
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get roles assigned to a user
|
|
200
|
-
* @param id - The user ID
|
|
201
|
-
* @returns Promise with the user's roles
|
|
202
|
-
*/
|
|
203
|
-
getUserRoles(id) {
|
|
204
|
-
return this.rest.request({
|
|
205
|
-
method: "GET",
|
|
206
|
-
url: `/api/identity/users/${id}/roles`
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Get all roles that can be assigned to users.
|
|
211
|
-
* This returns the list of available roles for user assignment.
|
|
212
|
-
* @since 3.0.0
|
|
213
|
-
* @returns Promise with assignable roles
|
|
214
|
-
*/
|
|
215
|
-
getUserAssignableRoles() {
|
|
216
|
-
return this.rest.request({
|
|
217
|
-
method: "GET",
|
|
218
|
-
url: "/api/identity/users/assignable-roles"
|
|
219
|
-
});
|
|
95
|
+
/**
|
|
96
|
+
* Create a new role
|
|
97
|
+
* @param input - The role data to create
|
|
98
|
+
* @returns Promise with the created role
|
|
99
|
+
*/
|
|
100
|
+
this.create = (input) => {
|
|
101
|
+
return this.restService.request({
|
|
102
|
+
method: "POST",
|
|
103
|
+
url: "/api/identity/roles",
|
|
104
|
+
body: input
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Delete a role by ID
|
|
109
|
+
* @param id - The role ID to delete
|
|
110
|
+
* @returns Promise that resolves when deletion is complete
|
|
111
|
+
*/
|
|
112
|
+
this.delete = (id) => {
|
|
113
|
+
return this.restService.request({
|
|
114
|
+
method: "DELETE",
|
|
115
|
+
url: `/api/identity/roles/${id}`
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Get a role by ID
|
|
120
|
+
* @param id - The role ID
|
|
121
|
+
* @returns Promise with the role
|
|
122
|
+
*/
|
|
123
|
+
this.get = (id) => {
|
|
124
|
+
return this.restService.request({
|
|
125
|
+
method: "GET",
|
|
126
|
+
url: `/api/identity/roles/${id}`
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Get all roles without pagination
|
|
131
|
+
* @returns Promise with all roles
|
|
132
|
+
*/
|
|
133
|
+
this.getAllList = () => {
|
|
134
|
+
return this.restService.request({
|
|
135
|
+
method: "GET",
|
|
136
|
+
url: "/api/identity/roles/all"
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Get roles with pagination
|
|
141
|
+
* @param input - Pagination and sorting parameters
|
|
142
|
+
* @returns Promise with paginated roles
|
|
143
|
+
*/
|
|
144
|
+
this.getList = (input) => {
|
|
145
|
+
return this.restService.request({
|
|
146
|
+
method: "GET",
|
|
147
|
+
url: "/api/identity/roles",
|
|
148
|
+
params: input
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Update a role
|
|
153
|
+
* @param id - The role ID to update
|
|
154
|
+
* @param input - The updated role data
|
|
155
|
+
* @returns Promise with the updated role
|
|
156
|
+
*/
|
|
157
|
+
this.update = (id, input) => {
|
|
158
|
+
return this.restService.request({
|
|
159
|
+
method: "PUT",
|
|
160
|
+
url: `/api/identity/roles/${id}`,
|
|
161
|
+
body: input
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
this.restService = restService;
|
|
220
165
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/proxy/identity/identity-user-lookup.service.ts
|
|
169
|
+
var IdentityUserLookupService = class {
|
|
170
|
+
constructor(restService) {
|
|
171
|
+
/**
|
|
172
|
+
* The API name used for REST requests.
|
|
173
|
+
*/
|
|
174
|
+
this.apiName = "default";
|
|
175
|
+
/**
|
|
176
|
+
* Find a user by ID
|
|
177
|
+
* @param id - The user ID
|
|
178
|
+
* @returns Promise with the user data
|
|
179
|
+
*/
|
|
180
|
+
this.findById = (id) => {
|
|
181
|
+
return this.restService.request({
|
|
182
|
+
method: "GET",
|
|
183
|
+
url: `/api/identity/users/lookup/${id}`
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Find a user by username
|
|
188
|
+
* @param userName - The username to search for
|
|
189
|
+
* @returns Promise with the user data
|
|
190
|
+
*/
|
|
191
|
+
this.findByUserName = (userName) => {
|
|
192
|
+
return this.restService.request({
|
|
193
|
+
method: "GET",
|
|
194
|
+
url: `/api/identity/users/lookup/by-username/${userName}`
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Get count of users matching filter
|
|
199
|
+
* @param input - Filter parameters
|
|
200
|
+
* @returns Promise with the count
|
|
201
|
+
*/
|
|
202
|
+
this.getCount = (input) => {
|
|
203
|
+
return this.restService.request({
|
|
204
|
+
method: "GET",
|
|
205
|
+
url: "/api/identity/users/lookup/count",
|
|
206
|
+
params: input
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Search for users
|
|
211
|
+
* @param input - Search and pagination parameters
|
|
212
|
+
* @returns Promise with matching users
|
|
213
|
+
*/
|
|
214
|
+
this.search = (input) => {
|
|
215
|
+
return this.restService.request({
|
|
216
|
+
method: "GET",
|
|
217
|
+
url: "/api/identity/users/lookup/search",
|
|
218
|
+
params: input
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
this.restService = restService;
|
|
231
222
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// src/proxy/identity/identity-user.service.ts
|
|
226
|
+
var IdentityUserService = class {
|
|
227
|
+
constructor(restService) {
|
|
228
|
+
/**
|
|
229
|
+
* The API name used for REST requests.
|
|
230
|
+
*/
|
|
231
|
+
this.apiName = "default";
|
|
232
|
+
/**
|
|
233
|
+
* Create a new user
|
|
234
|
+
* @param input - The user data to create
|
|
235
|
+
* @returns Promise with the created user
|
|
236
|
+
*/
|
|
237
|
+
this.create = (input) => {
|
|
238
|
+
return this.restService.request({
|
|
239
|
+
method: "POST",
|
|
240
|
+
url: "/api/identity/users",
|
|
241
|
+
body: input
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Delete a user by ID
|
|
246
|
+
* @param id - The user ID to delete
|
|
247
|
+
* @returns Promise that resolves when deletion is complete
|
|
248
|
+
*/
|
|
249
|
+
this.delete = (id) => {
|
|
250
|
+
return this.restService.request({
|
|
251
|
+
method: "DELETE",
|
|
252
|
+
url: `/api/identity/users/${id}`
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Find a user by email
|
|
257
|
+
* @param email - The user's email
|
|
258
|
+
* @returns Promise with the user
|
|
259
|
+
*/
|
|
260
|
+
this.findByEmail = (email) => {
|
|
261
|
+
return this.restService.request({
|
|
262
|
+
method: "GET",
|
|
263
|
+
url: `/api/identity/users/by-email/${email}`
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Find a user by username
|
|
268
|
+
* @param username - The user's username
|
|
269
|
+
* @returns Promise with the user
|
|
270
|
+
*/
|
|
271
|
+
this.findByUsername = (username) => {
|
|
272
|
+
return this.restService.request({
|
|
273
|
+
method: "GET",
|
|
274
|
+
url: `/api/identity/users/by-username/${username}`
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Get a user by ID
|
|
279
|
+
* @param id - The user ID
|
|
280
|
+
* @returns Promise with the user
|
|
281
|
+
*/
|
|
282
|
+
this.get = (id) => {
|
|
283
|
+
return this.restService.request({
|
|
284
|
+
method: "GET",
|
|
285
|
+
url: `/api/identity/users/${id}`
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Get all roles that can be assigned to users
|
|
290
|
+
* @returns Promise with assignable roles
|
|
291
|
+
*/
|
|
292
|
+
this.getAssignableRoles = () => {
|
|
293
|
+
return this.restService.request({
|
|
294
|
+
method: "GET",
|
|
295
|
+
url: "/api/identity/users/assignable-roles"
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Get users with pagination and filtering
|
|
300
|
+
* @param input - Pagination, sorting, and filter parameters
|
|
301
|
+
* @returns Promise with paginated users
|
|
302
|
+
*/
|
|
303
|
+
this.getList = (input) => {
|
|
304
|
+
return this.restService.request({
|
|
305
|
+
method: "GET",
|
|
306
|
+
url: "/api/identity/users",
|
|
307
|
+
params: input
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Get roles assigned to a user
|
|
312
|
+
* @param id - The user ID
|
|
313
|
+
* @returns Promise with the user's roles
|
|
314
|
+
*/
|
|
315
|
+
this.getRoles = (id) => {
|
|
316
|
+
return this.restService.request({
|
|
317
|
+
method: "GET",
|
|
318
|
+
url: `/api/identity/users/${id}/roles`
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Update a user
|
|
323
|
+
* @param id - The user ID to update
|
|
324
|
+
* @param input - The updated user data
|
|
325
|
+
* @returns Promise with the updated user
|
|
326
|
+
*/
|
|
327
|
+
this.update = (id, input) => {
|
|
328
|
+
return this.restService.request({
|
|
329
|
+
method: "PUT",
|
|
330
|
+
url: `/api/identity/users/${id}`,
|
|
331
|
+
body: input
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Update a user's roles
|
|
336
|
+
* @param id - The user ID
|
|
337
|
+
* @param input - The new role assignments
|
|
338
|
+
* @returns Promise that resolves when update is complete
|
|
339
|
+
*/
|
|
340
|
+
this.updateRoles = (id, input) => {
|
|
341
|
+
return this.restService.request({
|
|
342
|
+
method: "PUT",
|
|
343
|
+
url: `/api/identity/users/${id}/roles`,
|
|
344
|
+
body: input
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
this.restService = restService;
|
|
243
348
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// src/proxy/identity/profile.service.ts
|
|
352
|
+
var ProfileService = class {
|
|
353
|
+
constructor(restService) {
|
|
354
|
+
/**
|
|
355
|
+
* The API name used for REST requests.
|
|
356
|
+
*/
|
|
357
|
+
this.apiName = "default";
|
|
358
|
+
/**
|
|
359
|
+
* Change the current user's password
|
|
360
|
+
* @param input - Current and new password
|
|
361
|
+
* @returns Promise that resolves when password is changed
|
|
362
|
+
*/
|
|
363
|
+
this.changePassword = (input) => {
|
|
364
|
+
return this.restService.request({
|
|
365
|
+
method: "POST",
|
|
366
|
+
url: "/api/identity/my-profile/change-password",
|
|
367
|
+
body: input
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Get the current user's profile
|
|
372
|
+
* @returns Promise with the profile data
|
|
373
|
+
*/
|
|
374
|
+
this.get = () => {
|
|
375
|
+
return this.restService.request({
|
|
376
|
+
method: "GET",
|
|
377
|
+
url: "/api/identity/my-profile"
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Update the current user's profile
|
|
382
|
+
* @param input - Updated profile data
|
|
383
|
+
* @returns Promise with the updated profile
|
|
384
|
+
*/
|
|
385
|
+
this.update = (input) => {
|
|
386
|
+
return this.restService.request({
|
|
387
|
+
method: "PUT",
|
|
388
|
+
url: "/api/identity/my-profile",
|
|
389
|
+
body: input
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
this.restService = restService;
|
|
256
393
|
}
|
|
257
394
|
};
|
|
258
395
|
|
|
259
396
|
// src/services/identity-state.service.ts
|
|
260
397
|
var IdentityStateService = class {
|
|
261
|
-
constructor(
|
|
398
|
+
constructor(identityRoleService, identityUserService) {
|
|
262
399
|
// Internal state
|
|
263
400
|
this.roles = [];
|
|
264
401
|
this.rolesTotalCount = 0;
|
|
265
402
|
this.users = [];
|
|
266
403
|
this.usersTotalCount = 0;
|
|
267
|
-
this.
|
|
404
|
+
this.identityRoleService = identityRoleService;
|
|
405
|
+
this.identityUserService = identityUserService;
|
|
268
406
|
}
|
|
269
407
|
// ========================
|
|
270
408
|
// State Getters
|
|
271
409
|
// ========================
|
|
272
410
|
/**
|
|
273
411
|
* Get the current roles from state
|
|
412
|
+
* @updated 4.0.0 - Returns IdentityRoleDto[] instead of Identity.RoleItem[]
|
|
274
413
|
*/
|
|
275
414
|
getRoles() {
|
|
276
415
|
return this.roles;
|
|
@@ -283,6 +422,7 @@ var IdentityStateService = class {
|
|
|
283
422
|
}
|
|
284
423
|
/**
|
|
285
424
|
* Get the current users from state
|
|
425
|
+
* @updated 4.0.0 - Returns IdentityUserDto[] instead of Identity.UserItem[]
|
|
286
426
|
*/
|
|
287
427
|
getUsers() {
|
|
288
428
|
return this.users;
|
|
@@ -298,12 +438,12 @@ var IdentityStateService = class {
|
|
|
298
438
|
// ========================
|
|
299
439
|
/**
|
|
300
440
|
* Fetch roles and update internal state
|
|
301
|
-
* @param params - Optional
|
|
441
|
+
* @param params - Optional pagination/sorting parameters
|
|
302
442
|
*/
|
|
303
443
|
async dispatchGetRoles(params) {
|
|
304
|
-
const response = await this.
|
|
305
|
-
this.roles = response.items;
|
|
306
|
-
this.rolesTotalCount = response.totalCount;
|
|
444
|
+
const response = await this.identityRoleService.getList(params || {});
|
|
445
|
+
this.roles = response.items ?? [];
|
|
446
|
+
this.rolesTotalCount = response.totalCount ?? 0;
|
|
307
447
|
return response;
|
|
308
448
|
}
|
|
309
449
|
/**
|
|
@@ -311,23 +451,22 @@ var IdentityStateService = class {
|
|
|
311
451
|
* @param id - The role ID
|
|
312
452
|
*/
|
|
313
453
|
async dispatchGetRoleById(id) {
|
|
314
|
-
return this.
|
|
454
|
+
return this.identityRoleService.get(id);
|
|
315
455
|
}
|
|
316
456
|
/**
|
|
317
457
|
* Delete a role and refresh the list
|
|
318
458
|
* @param id - The role ID to delete
|
|
319
459
|
*/
|
|
320
460
|
async dispatchDeleteRole(id) {
|
|
321
|
-
|
|
461
|
+
await this.identityRoleService.delete(id);
|
|
322
462
|
await this.dispatchGetRoles();
|
|
323
|
-
return result;
|
|
324
463
|
}
|
|
325
464
|
/**
|
|
326
465
|
* Create a new role and refresh the list
|
|
327
466
|
* @param body - The role data to create
|
|
328
467
|
*/
|
|
329
468
|
async dispatchCreateRole(body) {
|
|
330
|
-
const result = await this.
|
|
469
|
+
const result = await this.identityRoleService.create(body);
|
|
331
470
|
await this.dispatchGetRoles();
|
|
332
471
|
return result;
|
|
333
472
|
}
|
|
@@ -336,7 +475,7 @@ var IdentityStateService = class {
|
|
|
336
475
|
* @param payload - Object containing id and updated role data
|
|
337
476
|
*/
|
|
338
477
|
async dispatchUpdateRole(payload) {
|
|
339
|
-
const result = await this.
|
|
478
|
+
const result = await this.identityRoleService.update(payload.id, payload.body);
|
|
340
479
|
await this.dispatchGetRoles();
|
|
341
480
|
return result;
|
|
342
481
|
}
|
|
@@ -348,9 +487,9 @@ var IdentityStateService = class {
|
|
|
348
487
|
* @param params - Optional query parameters for pagination/filtering
|
|
349
488
|
*/
|
|
350
489
|
async dispatchGetUsers(params) {
|
|
351
|
-
const response = await this.
|
|
352
|
-
this.users = response.items;
|
|
353
|
-
this.usersTotalCount = response.totalCount;
|
|
490
|
+
const response = await this.identityUserService.getList(params || {});
|
|
491
|
+
this.users = response.items ?? [];
|
|
492
|
+
this.usersTotalCount = response.totalCount ?? 0;
|
|
354
493
|
return response;
|
|
355
494
|
}
|
|
356
495
|
/**
|
|
@@ -358,14 +497,14 @@ var IdentityStateService = class {
|
|
|
358
497
|
* @param id - The user ID
|
|
359
498
|
*/
|
|
360
499
|
async dispatchGetUserById(id) {
|
|
361
|
-
return this.
|
|
500
|
+
return this.identityUserService.get(id);
|
|
362
501
|
}
|
|
363
502
|
/**
|
|
364
503
|
* Delete a user and refresh the list
|
|
365
504
|
* @param id - The user ID to delete
|
|
366
505
|
*/
|
|
367
506
|
async dispatchDeleteUser(id) {
|
|
368
|
-
await this.
|
|
507
|
+
await this.identityUserService.delete(id);
|
|
369
508
|
await this.dispatchGetUsers();
|
|
370
509
|
}
|
|
371
510
|
/**
|
|
@@ -373,7 +512,7 @@ var IdentityStateService = class {
|
|
|
373
512
|
* @param body - The user data to create
|
|
374
513
|
*/
|
|
375
514
|
async dispatchCreateUser(body) {
|
|
376
|
-
const result = await this.
|
|
515
|
+
const result = await this.identityUserService.create(body);
|
|
377
516
|
await this.dispatchGetUsers();
|
|
378
517
|
return result;
|
|
379
518
|
}
|
|
@@ -382,7 +521,7 @@ var IdentityStateService = class {
|
|
|
382
521
|
* @param payload - Object containing id and updated user data
|
|
383
522
|
*/
|
|
384
523
|
async dispatchUpdateUser(payload) {
|
|
385
|
-
const result = await this.
|
|
524
|
+
const result = await this.identityUserService.update(payload.id, payload.body);
|
|
386
525
|
await this.dispatchGetUsers();
|
|
387
526
|
return result;
|
|
388
527
|
}
|
|
@@ -391,7 +530,7 @@ var IdentityStateService = class {
|
|
|
391
530
|
* @param id - The user ID
|
|
392
531
|
*/
|
|
393
532
|
async dispatchGetUserRoles(id) {
|
|
394
|
-
return this.
|
|
533
|
+
return this.identityUserService.getRoles(id);
|
|
395
534
|
}
|
|
396
535
|
};
|
|
397
536
|
|
|
@@ -400,7 +539,7 @@ import { useState, useCallback, useMemo } from "react";
|
|
|
400
539
|
import { useRestService } from "@abpjs/core";
|
|
401
540
|
function useRoles() {
|
|
402
541
|
const restService = useRestService();
|
|
403
|
-
const service = useMemo(() => new
|
|
542
|
+
const service = useMemo(() => new IdentityRoleService(restService), [restService]);
|
|
404
543
|
const [roles, setRoles] = useState([]);
|
|
405
544
|
const [totalCount, setTotalCount] = useState(0);
|
|
406
545
|
const [selectedRole, setSelectedRole] = useState(null);
|
|
@@ -412,7 +551,7 @@ function useRoles() {
|
|
|
412
551
|
setIsLoading(true);
|
|
413
552
|
setError(null);
|
|
414
553
|
try {
|
|
415
|
-
const response = await service.
|
|
554
|
+
const response = await service.getList(params || {});
|
|
416
555
|
setRoles(response.items || []);
|
|
417
556
|
setTotalCount(response.totalCount || 0);
|
|
418
557
|
setIsLoading(false);
|
|
@@ -429,7 +568,7 @@ function useRoles() {
|
|
|
429
568
|
setIsLoading(true);
|
|
430
569
|
setError(null);
|
|
431
570
|
try {
|
|
432
|
-
const role = await service.
|
|
571
|
+
const role = await service.get(id);
|
|
433
572
|
setSelectedRole(role);
|
|
434
573
|
setIsLoading(false);
|
|
435
574
|
return { success: true };
|
|
@@ -447,7 +586,7 @@ function useRoles() {
|
|
|
447
586
|
setIsLoading(true);
|
|
448
587
|
setError(null);
|
|
449
588
|
try {
|
|
450
|
-
await service.
|
|
589
|
+
await service.create(role);
|
|
451
590
|
await fetchRoles();
|
|
452
591
|
return { success: true };
|
|
453
592
|
} catch (err) {
|
|
@@ -464,7 +603,7 @@ function useRoles() {
|
|
|
464
603
|
setIsLoading(true);
|
|
465
604
|
setError(null);
|
|
466
605
|
try {
|
|
467
|
-
await service.
|
|
606
|
+
await service.update(id, role);
|
|
468
607
|
await fetchRoles();
|
|
469
608
|
return { success: true };
|
|
470
609
|
} catch (err) {
|
|
@@ -481,7 +620,7 @@ function useRoles() {
|
|
|
481
620
|
setIsLoading(true);
|
|
482
621
|
setError(null);
|
|
483
622
|
try {
|
|
484
|
-
await service.
|
|
623
|
+
await service.delete(id);
|
|
485
624
|
await fetchRoles();
|
|
486
625
|
return { success: true };
|
|
487
626
|
} catch (err) {
|
|
@@ -524,13 +663,14 @@ function useRoles() {
|
|
|
524
663
|
import { useState as useState2, useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
525
664
|
import { useRestService as useRestService2 } from "@abpjs/core";
|
|
526
665
|
var DEFAULT_PAGE_QUERY = {
|
|
666
|
+
filter: "",
|
|
527
667
|
sorting: "userName",
|
|
528
668
|
skipCount: 0,
|
|
529
669
|
maxResultCount: 10
|
|
530
670
|
};
|
|
531
671
|
function useUsers() {
|
|
532
672
|
const restService = useRestService2();
|
|
533
|
-
const service = useMemo2(() => new
|
|
673
|
+
const service = useMemo2(() => new IdentityUserService(restService), [restService]);
|
|
534
674
|
const [users, setUsers] = useState2([]);
|
|
535
675
|
const [totalCount, setTotalCount] = useState2(0);
|
|
536
676
|
const [selectedUser, setSelectedUser] = useState2(null);
|
|
@@ -546,7 +686,7 @@ function useUsers() {
|
|
|
546
686
|
setError(null);
|
|
547
687
|
const queryParams = params || pageQuery;
|
|
548
688
|
try {
|
|
549
|
-
const response = await service.
|
|
689
|
+
const response = await service.getList(queryParams);
|
|
550
690
|
setUsers(response.items || []);
|
|
551
691
|
setTotalCount(response.totalCount || 0);
|
|
552
692
|
setIsLoading(false);
|
|
@@ -565,7 +705,7 @@ function useUsers() {
|
|
|
565
705
|
setIsLoading(true);
|
|
566
706
|
setError(null);
|
|
567
707
|
try {
|
|
568
|
-
const user = await service.
|
|
708
|
+
const user = await service.get(id);
|
|
569
709
|
setSelectedUser(user);
|
|
570
710
|
setIsLoading(false);
|
|
571
711
|
return { success: true };
|
|
@@ -583,7 +723,7 @@ function useUsers() {
|
|
|
583
723
|
setIsLoading(true);
|
|
584
724
|
setError(null);
|
|
585
725
|
try {
|
|
586
|
-
const response = await service.
|
|
726
|
+
const response = await service.getRoles(id);
|
|
587
727
|
setSelectedUserRoles(response.items || []);
|
|
588
728
|
setIsLoading(false);
|
|
589
729
|
return { success: true };
|
|
@@ -601,7 +741,7 @@ function useUsers() {
|
|
|
601
741
|
setIsLoading(true);
|
|
602
742
|
setError(null);
|
|
603
743
|
try {
|
|
604
|
-
await service.
|
|
744
|
+
await service.create(user);
|
|
605
745
|
await fetchUsers();
|
|
606
746
|
return { success: true };
|
|
607
747
|
} catch (err) {
|
|
@@ -618,7 +758,7 @@ function useUsers() {
|
|
|
618
758
|
setIsLoading(true);
|
|
619
759
|
setError(null);
|
|
620
760
|
try {
|
|
621
|
-
await service.
|
|
761
|
+
await service.update(id, user);
|
|
622
762
|
await fetchUsers();
|
|
623
763
|
return { success: true };
|
|
624
764
|
} catch (err) {
|
|
@@ -635,7 +775,7 @@ function useUsers() {
|
|
|
635
775
|
setIsLoading(true);
|
|
636
776
|
setError(null);
|
|
637
777
|
try {
|
|
638
|
-
await service.
|
|
778
|
+
await service.delete(id);
|
|
639
779
|
await fetchUsers();
|
|
640
780
|
return { success: true };
|
|
641
781
|
} catch (err) {
|
|
@@ -814,11 +954,15 @@ function RolesComponent({
|
|
|
814
954
|
const roleData = {
|
|
815
955
|
name: formState.name.trim(),
|
|
816
956
|
isDefault: formState.isDefault,
|
|
817
|
-
isPublic: formState.isPublic
|
|
957
|
+
isPublic: formState.isPublic,
|
|
958
|
+
extraProperties: {}
|
|
818
959
|
};
|
|
819
960
|
let result;
|
|
820
961
|
if (selectedRole?.id) {
|
|
821
|
-
result = await updateRole(selectedRole.id,
|
|
962
|
+
result = await updateRole(selectedRole.id, {
|
|
963
|
+
...roleData,
|
|
964
|
+
concurrencyStamp: selectedRole.concurrencyStamp
|
|
965
|
+
});
|
|
822
966
|
if (result.success) {
|
|
823
967
|
onRoleUpdated?.({ ...selectedRole, ...roleData });
|
|
824
968
|
}
|
|
@@ -978,7 +1122,6 @@ var DEFAULT_FORM_STATE2 = {
|
|
|
978
1122
|
phoneNumber: "",
|
|
979
1123
|
password: "",
|
|
980
1124
|
lockoutEnabled: true,
|
|
981
|
-
twoFactorEnabled: true,
|
|
982
1125
|
roleNames: []
|
|
983
1126
|
};
|
|
984
1127
|
function getPasswordRuleLabel(rule, t) {
|
|
@@ -1043,7 +1186,7 @@ function UsersComponent({
|
|
|
1043
1186
|
useEffect2(() => {
|
|
1044
1187
|
const newQuery = {
|
|
1045
1188
|
...pageQuery,
|
|
1046
|
-
filter: debouncedSearchTerm ||
|
|
1189
|
+
filter: debouncedSearchTerm || "",
|
|
1047
1190
|
skipCount: 0
|
|
1048
1191
|
};
|
|
1049
1192
|
setPageQuery(newQuery);
|
|
@@ -1074,7 +1217,6 @@ function UsersComponent({
|
|
|
1074
1217
|
phoneNumber: selectedUser.phoneNumber || "",
|
|
1075
1218
|
password: "",
|
|
1076
1219
|
lockoutEnabled: selectedUser.lockoutEnabled ?? true,
|
|
1077
|
-
twoFactorEnabled: selectedUser.twoFactorEnabled ?? true,
|
|
1078
1220
|
roleNames: selectedRoleNames
|
|
1079
1221
|
});
|
|
1080
1222
|
}
|
|
@@ -1110,12 +1252,15 @@ function UsersComponent({
|
|
|
1110
1252
|
phoneNumber: formState.phoneNumber.trim(),
|
|
1111
1253
|
password: formState.password,
|
|
1112
1254
|
lockoutEnabled: formState.lockoutEnabled,
|
|
1113
|
-
|
|
1114
|
-
|
|
1255
|
+
roleNames: formState.roleNames,
|
|
1256
|
+
extraProperties: {}
|
|
1115
1257
|
};
|
|
1116
1258
|
let result;
|
|
1117
1259
|
if (selectedUser?.id) {
|
|
1118
|
-
result = await updateUser(selectedUser.id,
|
|
1260
|
+
result = await updateUser(selectedUser.id, {
|
|
1261
|
+
...userData,
|
|
1262
|
+
concurrencyStamp: selectedUser.concurrencyStamp
|
|
1263
|
+
});
|
|
1119
1264
|
if (result.success) {
|
|
1120
1265
|
onUserUpdated?.({
|
|
1121
1266
|
...selectedUser,
|
|
@@ -1128,10 +1273,8 @@ function UsersComponent({
|
|
|
1128
1273
|
onUserCreated?.({
|
|
1129
1274
|
...userData,
|
|
1130
1275
|
id: "",
|
|
1131
|
-
tenantId: "",
|
|
1132
1276
|
emailConfirmed: false,
|
|
1133
1277
|
phoneNumberConfirmed: false,
|
|
1134
|
-
isLockedOut: false,
|
|
1135
1278
|
concurrencyStamp: ""
|
|
1136
1279
|
});
|
|
1137
1280
|
}
|
|
@@ -1341,14 +1484,6 @@ function UsersComponent({
|
|
|
1341
1484
|
onChange: (e) => handleInputChange("lockoutEnabled", e.target.checked),
|
|
1342
1485
|
children: t("AbpIdentity::DisplayName:LockoutEnabled")
|
|
1343
1486
|
}
|
|
1344
|
-
),
|
|
1345
|
-
/* @__PURE__ */ jsx2(
|
|
1346
|
-
Checkbox2,
|
|
1347
|
-
{
|
|
1348
|
-
checked: formState.twoFactorEnabled,
|
|
1349
|
-
onChange: (e) => handleInputChange("twoFactorEnabled", e.target.checked),
|
|
1350
|
-
children: t("AbpIdentity::DisplayName:TwoFactorEnabled")
|
|
1351
|
-
}
|
|
1352
1487
|
)
|
|
1353
1488
|
] }) }),
|
|
1354
1489
|
/* @__PURE__ */ jsx2(Tabs.Content, { value: "roles", children: /* @__PURE__ */ jsxs2(VStack2, { gap: 2, align: "stretch", pt: 4, children: [
|
|
@@ -1413,8 +1548,11 @@ export {
|
|
|
1413
1548
|
IDENTITY_POLICIES,
|
|
1414
1549
|
IDENTITY_ROUTE_PATHS,
|
|
1415
1550
|
IDENTITY_ROUTE_PROVIDERS,
|
|
1416
|
-
|
|
1551
|
+
IdentityRoleService,
|
|
1417
1552
|
IdentityStateService,
|
|
1553
|
+
IdentityUserLookupService,
|
|
1554
|
+
IdentityUserService,
|
|
1555
|
+
ProfileService,
|
|
1418
1556
|
RolesComponent,
|
|
1419
1557
|
UsersComponent,
|
|
1420
1558
|
configureRoutes,
|