Commit 01c8b063 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Provisions for a dynamic credential list

parent a1f0402f
......@@ -95,7 +95,6 @@ lwt election_table =
election;
fn_public_keys;
public_creds;
fn_public_creds;
featured_p = true;
can_read = Any;
can_vote;
......@@ -273,14 +272,17 @@ let () = Eliom_registration.File.register
)
)
let () = Eliom_registration.File.register
let () = Eliom_registration.Streamlist.register
~service:Services.election_public_creds
~content_type:"text/plain"
(if_eligible can_read
(fun uuid election user () ->
let module X = (val election : Web_common.WEB_ELECTION) in
return X.data.Web_common.fn_public_creds
)
lwt creds = X.B.extract_creds () in
let s = Web_common.SSet.fold (fun x accu ->
(fun () -> return (Ocsigen_stream.of_string (x^"\n"))) :: accu
) creds [] in
return (List.rev s, "text/plain")
)
)
let () = Eliom_registration.Streamlist.register
......
......@@ -32,7 +32,6 @@ type election_data = {
election : ff_pubkey election;
fn_public_keys : string;
public_creds : SSet.t;
fn_public_creds : string;
featured_p : bool;
can_read : acl;
can_vote : acl;
......@@ -106,6 +105,7 @@ module type WEB_BBOX = sig
and type record = string * datetime
val inject_creds : SSet.t -> unit Lwt.t
val extract_creds : unit -> SSet.t Lwt.t
end
module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struct
......@@ -124,10 +124,13 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
type ballot = string
type record = string * Serializable_builtin_t.datetime
let inject_creds creds =
lwt existing_creds = Ocsipersist.fold_step (fun k v x ->
let extract_creds () =
Ocsipersist.fold_step (fun k v x ->
return (SSet.add k x)
) cred_table SSet.empty in
) cred_table SSet.empty
let inject_creds creds =
lwt existing_creds = extract_creds () in
if SSet.is_empty existing_creds then (
Ocsigen_messages.debug (fun () ->
"-- injecting credentials"
......
......@@ -23,7 +23,6 @@ type election_data = {
election : ff_pubkey election;
fn_public_keys : string;
public_creds : SSet.t;
fn_public_creds : string;
featured_p : bool;
can_read : acl;
can_vote : acl;
......@@ -67,6 +66,7 @@ module type WEB_BBOX = sig
and type record = string * datetime
val inject_creds : SSet.t -> unit Lwt.t
val extract_creds : unit -> SSet.t Lwt.t
end
module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) : WEB_BBOX
......
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