mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-09 16:24:51 +00:00
Make creating users a special case in dataProvider
Since users are created with PUT instead of POST, this is actually a special case. Change-Id: Ibe430fcac4d81de9723abd650804ffa93f87bf6d
This commit is contained in:
parent
1e6e526e3c
commit
437fd70d6d
1 changed files with 11 additions and 4 deletions
|
@ -30,6 +30,11 @@ const resourceMap = {
|
|||
? parseInt(json.next_token, 10) + perPage
|
||||
: from + json.users.length;
|
||||
},
|
||||
create: data => ({
|
||||
endpoint: `/_synapse/admin/v2/users/${data.id}`,
|
||||
body: data,
|
||||
method: "PUT",
|
||||
}),
|
||||
delete: id => ({
|
||||
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||
body: { erase: true },
|
||||
|
@ -190,11 +195,13 @@ const dataProvider = {
|
|||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||
|
||||
const res = resourceMap[resource];
|
||||
if (!("create" in res)) return Promise.reject();
|
||||
|
||||
const endpoint_url = homeserver + res.path;
|
||||
return jsonClient(`${endpoint_url}/${params.data.id}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(params.data, filterNullValues),
|
||||
const create = res["create"](params.data);
|
||||
const endpoint_url = homeserver + create.endpoint;
|
||||
return jsonClient(endpoint_url, {
|
||||
method: create.method,
|
||||
body: JSON.stringify(create.body, filterNullValues),
|
||||
}).then(({ json }) => ({
|
||||
data: res.map(json),
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue