Commit c7d3ee59 authored by Stephane Glondu's avatar Stephane Glondu

Add possibility to destroy elections in setup mode

parent 97c1ce05
......@@ -67,6 +67,7 @@ let election_setup_threshold_trustee_del = post_coservice ~fallback:election_set
let election_setup_confirm = service ~path:["setup"; "confirm"] ~get_params:(uuid "uuid") ()
let election_setup_create = post_coservice ~csrf_safe:true ~fallback:election_setup ~post_params:unit ()
let election_setup_destroy = post_coservice ~csrf_safe:true ~fallback:election_setup ~post_params:unit ()
let election_setup_auth_genpwd = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_import = service ~path:["setup"; "import"] ~get_params:(uuid "uuid") ()
......
......@@ -955,6 +955,38 @@ let () =
)
)
let () =
Any.register ~service:election_setup_destroy
(fun uuid () ->
with_setup_election ~save:false uuid (fun se ->
let uuid_s = raw_string_of_uuid uuid in
(* clean up credentials *)
let%lwt () =
let fname = !spool_dir / uuid_s ^ ".public_creds.txt" in
try%lwt Lwt_unix.unlink fname
with _ -> return_unit
in
(* clean up setup database *)
let%lwt () = Ocsipersist.remove election_credtokens se.se_public_creds in
let%lwt () =
Lwt_list.iter_s (fun {st_token; _} ->
if st_token <> "" then
Ocsipersist.remove election_pktokens st_token
else return_unit
) se.se_public_keys
in
let%lwt () = match se.se_threshold_trustees with
| None -> return_unit
| Some ts ->
Lwt_list.iter_s (fun {stt_token; _} ->
Ocsipersist.remove election_tpktokens stt_token
) ts
in
let%lwt () = Ocsipersist.remove election_stable uuid_s in
Redirection.send admin
)
)
let () =
Html5.register ~service:election_setup_import
(fun uuid () ->
......
......@@ -477,6 +477,18 @@ let election_setup uuid se () =
h2 [pcdata "Finalize creation"];
a ~service:election_setup_confirm [pcdata "Create election"] uuid;
] in
let form_destroy =
post_form
~service:election_setup_destroy
(fun () ->
[
div [
h2 [pcdata "Destroy election"];
string_input ~input_type:`Submit ~value:"Destroy election" ();
]
]
) uuid
in
let content = [
div_description;
hr ();
......@@ -493,6 +505,8 @@ let election_setup uuid se () =
div_trustees;
hr ();
link_confirm;
hr ();
form_destroy;
] in
let%lwt login_box = site_login_box () in
base ~title ?login_box ~content ()
......
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