7
7
8
8
import { User } from 'oidc-client' ;
9
9
import { backendFetch , backendFetchJson , getRestBase } from '../utils/api-rest' ;
10
- import { extractUserSub , getToken , getUser } from '../utils/api' ;
10
+ import { extractUserSub , getToken } from '../utils/api' ;
11
11
import { UUID } from 'crypto' ;
12
12
13
13
const USER_ADMIN_URL = `${ getRestBase ( ) } /user-admin/v1` ;
14
14
15
- export function getUserSub ( ) : Promise < unknown > {
16
- return extractUserSub ( getUser ( ) ) ;
17
- }
18
-
19
15
/*
20
16
* fetchValidateUser is call from commons-ui AuthServices to validate user infos before setting state.user!
21
17
*/
@@ -40,7 +36,7 @@ export function fetchValidateUser(user: User): Promise<boolean> {
40
36
41
37
export type UserInfos = {
42
38
sub : string ;
43
- profileName : string ;
39
+ profileName ? : string ;
44
40
isAdmin : boolean ;
45
41
groups : string [ ] ;
46
42
} ;
@@ -59,14 +55,7 @@ export function fetchUsers(): Promise<UserInfos[]> {
59
55
} ) as Promise < UserInfos [ ] > ;
60
56
}
61
57
62
- export type UpdateUserInfos = {
63
- sub : string ;
64
- profileName ?: string ;
65
- isAdmin ?: boolean ;
66
- groups : string [ ] ;
67
- } ;
68
-
69
- export function udpateUser ( userInfos : UpdateUserInfos ) {
58
+ export function updateUser ( userInfos : UserInfos ) {
70
59
console . debug ( `Updating a user...` ) ;
71
60
72
61
return backendFetch ( `${ USER_ADMIN_URL } /users/${ userInfos . sub } ` , {
@@ -216,7 +205,7 @@ export function deleteProfiles(names: string[]): Promise<void> {
216
205
}
217
206
218
207
export type GroupInfos = {
219
- id ? : UUID ;
208
+ id : UUID ;
220
209
name : string ;
221
210
users : string [ ] ;
222
211
} ;
@@ -235,13 +224,7 @@ export function fetchGroups(): Promise<GroupInfos[]> {
235
224
} ) as Promise < GroupInfos [ ] > ;
236
225
}
237
226
238
- export type UpdateGroupInfos = {
239
- id : UUID ;
240
- name : string ;
241
- users : string [ ] ;
242
- } ;
243
-
244
- export function udpateGroup ( groupInfos : UpdateGroupInfos ) {
227
+ export function udpateGroup ( groupInfos : GroupInfos ) {
245
228
console . debug ( `Updating a group...` ) ;
246
229
247
230
return backendFetch ( `${ USER_ADMIN_URL } /groups/${ groupInfos . id } ` , {
0 commit comments