1:- module(bc_api_role, []).
5:- use_module(library(arouter)). 6
7:- use_module(bc_api_io). 8:- use_module(bc_api_auth). 9:- use_module(bc_api_actor). 10
11:- use_module(bc_role). 12
14
15:- route_get(api/roles,
16 bc_auth, roles). 17
18roles:-
19 bc_actor(User),
20 check_admin(User),
21 findall(
22 _{ name: Name,
23 label: Label,
24 login: Login },
25 bc_role(Name, Label, Login), Roles),
26 bc_reply_success(Roles).
27
29
30check_admin(User):-
31 User.type = admin, !.
32
33check_admin(_):-
34 throw(error(no_access))
Role API handlers */