Commit d9b33502 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add is_admin to access the record list

parent f5444218
...@@ -257,18 +257,19 @@ let () = Eliom_registration.Streamlist.register ...@@ -257,18 +257,19 @@ let () = Eliom_registration.Streamlist.register
~service:Services.election_records ~service:Services.election_records
(if_eligible can_read (if_eligible can_read
(fun uuid election user () -> (fun uuid election user () ->
forbidden () >> (* FIXME *) if Web_common.is_admin user then (
let module X = (val election : Web_common.WEB_ELECTION) in let module X = (val election : Web_common.WEB_ELECTION) in
(* TODO: streaming *) (* TODO: streaming *)
lwt ballots = X.B.fold_records (fun (u, d) xs -> lwt ballots = X.B.fold_records (fun (u, d) xs ->
let x = Printf.sprintf "%s %S\n" let x = Printf.sprintf "%s %S\n"
(Serializable_builtin_j.string_of_datetime d) u (Serializable_builtin_j.string_of_datetime d) u
in return (x::xs) in return (x::xs)
) [] in ) [] in
let s = List.map (fun b () -> let s = List.map (fun b () ->
return (Ocsigen_stream.of_string b) return (Ocsigen_stream.of_string b)
) ballots in ) ballots in
return (s, "text/plain") return (s, "text/plain")
) else forbidden ()
) )
) )
......
...@@ -14,6 +14,11 @@ let string_of_user {user_name; user_type} = ...@@ -14,6 +14,11 @@ let string_of_user {user_name; user_type} =
| Dummy -> Printf.sprintf "dummy:%s" user_name | Dummy -> Printf.sprintf "dummy:%s" user_name
| CAS -> user_name | CAS -> user_name
(* FIXME: use a dedicated user_type *)
let is_admin = function
| Some { user_name = "admin"; user_type = Dummy } -> true
| _ -> false
type acl = type acl =
| Any | Any
| Restricted of (user -> bool Lwt.t) | Restricted of (user -> bool Lwt.t)
......
...@@ -8,6 +8,7 @@ type user = { ...@@ -8,6 +8,7 @@ type user = {
} }
val string_of_user : user -> string val string_of_user : user -> string
val is_admin : user option -> bool
type acl = type acl =
| Any | Any
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment