Add proper permissions for role application routes, allow admins to access application api
This commit is contained in:
parent
b6abeb0994
commit
9c7b49e2b9
16 changed files with 287 additions and 112 deletions
|
@ -6,7 +6,7 @@ export default (name: string, description?: string): Promise<Role> => {
|
|||
http.post('/api/application/roles', {
|
||||
name, description,
|
||||
})
|
||||
.then(({ data }) => resolve(data))
|
||||
.then(({ data }) => resolve(data.attributes))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import http from '@/api/http';
|
||||
import { rawDataToAdminRole } from '@/api/transformers';
|
||||
|
||||
export interface Role {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string | null;
|
||||
sortId: number;
|
||||
}
|
||||
|
||||
export default (): Promise<Role[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get('/api/application/roles')
|
||||
.then(({ data }) => resolve(data || []))
|
||||
.then(({ data }) => resolve((data.data || []).map(rawDataToAdminRole)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Role } from '@/api/admin/roles/getRoles';
|
||||
import { Allocation } from '@/api/server/getServer';
|
||||
import { FractalResponseData } from '@/api/http';
|
||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
||||
|
@ -74,3 +75,9 @@ export const rawDataToServerEggVariable = ({ attributes }: FractalResponseData):
|
|||
isEditable: attributes.is_editable,
|
||||
rules: attributes.rules.split('|'),
|
||||
});
|
||||
|
||||
export const rawDataToAdminRole = ({ attributes }: FractalResponseData): Role => ({
|
||||
id: attributes.id,
|
||||
name: attributes.name,
|
||||
description: attributes.description,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue