Add basic permissions checking logic to frontend

This commit is contained in:
Dane Everitt 2020-03-28 17:25:04 -07:00
parent 7e0ac2c311
commit ab4c4e7e9e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 81 additions and 11 deletions

View file

@ -41,20 +41,23 @@ export const rawDataToServerObject = (data: any): Server => ({
port: data.sftp_details.port,
},
description: data.description ? ((data.description.length > 0) ? data.description : null) : null,
allocations: [{
allocations: [ {
ip: data.allocation.ip,
alias: null,
port: data.allocation.port,
default: true,
}],
} ],
limits: { ...data.limits },
featureLimits: { ...data.feature_limits },
});
export default (uuid: string): Promise<Server> => {
export default (uuid: string): Promise<[ Server, string[] ]> => {
return new Promise((resolve, reject) => {
http.get(`/api/client/servers/${uuid}`)
.then(response => resolve(rawDataToServerObject(response.data.attributes)))
.then(({ data }) => resolve([
rawDataToServerObject(data.attributes),
data.meta?.is_server_owner ? ['*'] : (data.meta?.user_permissions || []),
]))
.catch(reject);
});
};