-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagement.js
58 lines (47 loc) · 1.96 KB
/
management.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const fs = require('fs');
const path = require('path');
const authfi = require('./authfi')
const MANAGEMENT_API_BASE = '/api/v1/users'
async function getRegisteredUsers(page, size) {
let response = await authfi.getFromAuthFi(`${MANAGEMENT_API_BASE}?page=${page}&size=${size}`);
console.log('response from authfi server:', response)
return response.body;
}
async function updateUserState(userId, newState) {
console.log('updateUserState()');
let response = await authfi.putToAuthFi(`${MANAGEMENT_API_BASE}/${userId}`, JSON.stringify({state: newState}));
console.log('response from authfi server:', response)
return response.body;
}
async function deleteUserRegisterData(userId) {
console.log('deleteUserRegisterData()');
let response = await authfi.deleteFromAuthFi(`${MANAGEMENT_API_BASE}/${userId}`);
console.log('response from authfi server:', response)
return response.body;
}
async function getUserRegisterKeys(userId) {
console.log('getUserRegisterKeys()');
let response = await authfi.getFromAuthFi(`${MANAGEMENT_API_BASE}/${userId}/keys`);
console.log('response from authfi server:', response)
return response.body;
}
async function chageUserRegisterKeyName(userId, credentialId, newName) {
console.log('chageUserRegisterKeyName()');
let response = await authfi.putToAuthFi(
`${MANAGEMENT_API_BASE}/${userId}/keys/${credentialId}`, JSON.stringify({name: newName})
);
console.log('response from authfi server:', response)
return response.body;
}
async function deleteRegisterKey(userId, credentialId) {
console.log('deleteRegisterKey()');
let response = await authfi.deleteFromAuthFi(
`${MANAGEMENT_API_BASE}/${userId}/keys/${credentialId}`
);
console.log('response from authfi server:', response)
return response.body;
}
module.exports = {
getRegisteredUsers, updateUserState, deleteUserRegisterData,
getUserRegisterKeys, chageUserRegisterKeyName, deleteRegisterKey
}