forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetServerSubusers.ts
More file actions
21 lines (19 loc) · 860 Bytes
/
getServerSubusers.ts
File metadata and controls
21 lines (19 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import http, { FractalResponseData } from '@/api/http';
import { Subuser } from '@/state/server/subusers';
export const rawDataToServerSubuser = (data: FractalResponseData): Subuser => ({
uuid: data.attributes.uuid,
username: data.attributes.username,
email: data.attributes.email,
image: data.attributes.image,
twoFactorEnabled: data.attributes['2fa_enabled'],
createdAt: new Date(data.attributes.created_at),
permissions: data.attributes.permissions || [],
can: permission => (data.attributes.permissions || []).indexOf(permission) >= 0,
});
export default (uuid: string): Promise<Subuser[]> => {
return new Promise((resolve, reject) => {
http.get(`/api/client/servers/${uuid}/users`)
.then(({ data }) => resolve((data.data || []).map(rawDataToServerSubuser)))
.catch(reject);
});
};