2020-03-27 21:23:13 +00:00
|
|
|
import http from '@/api/http';
|
|
|
|
import { rawDataToServerSubuser } from '@/api/server/users/getServerSubusers';
|
|
|
|
import { Subuser } from '@/state/server/subusers';
|
|
|
|
|
|
|
|
interface Params {
|
|
|
|
email: string;
|
|
|
|
permissions: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (uuid: string, params: Params, subuser?: Subuser): Promise<Subuser> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.post(`/api/client/servers/${uuid}/users${subuser ? `/${subuser.uuid}` : ''}`, {
|
|
|
|
...params,
|
|
|
|
})
|
2022-06-26 19:13:52 +00:00
|
|
|
.then((data) => resolve(rawDataToServerSubuser(data.data)))
|
2020-03-27 21:23:13 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
2020-07-05 01:30:50 +00:00
|
|
|
};
|