Commit 6fb2d815 authored by Stephane Glondu's avatar Stephane Glondu

Do not allow modification of voter list once public creds are received

parent 06478179
......@@ -643,6 +643,7 @@ let () =
~service:election_setup_voters_add
(handle_setup
(fun se x _ uuid ->
if se.se_public_creds_received then forbidden () else (
let xs = Pcre.split x in
let () =
try
......@@ -653,17 +654,18 @@ let () =
se.se_voters <- se.se_voters @ List.map (fun sv_id ->
{sv_id; sv_password=false}
) xs;
return (redir_preapply election_setup_voters uuid)))
return (redir_preapply election_setup_voters uuid))))
let () =
Any.register
~service:election_setup_voters_remove
(handle_setup
(fun se voter _ uuid ->
if se.se_public_creds_received then forbidden () else (
se.se_voters <- List.filter (fun v ->
v.sv_id <> voter
) se.se_voters;
return (redir_preapply election_setup_voters uuid)))
return (redir_preapply election_setup_voters uuid))))
let () =
Redirection.register
......
......@@ -622,7 +622,7 @@ let election_setup_voters uuid se () =
tr (
[td [pcdata v.sv_id]] @
(if has_passwords then [td [pcdata (to_string v.sv_password)]] else []) @
[td [mk_remove_button v.sv_id]]
(if se.se_public_creds_received then [] else [td [mk_remove_button v.sv_id]])
)
) se.se_voters
in
......@@ -634,23 +634,31 @@ let election_setup_voters uuid se () =
(tr (
[th [pcdata "Identity"]] @
(if has_passwords then [th [pcdata "Password"]] else []) @
[th [pcdata "Remove"]]
(if se.se_public_creds_received then [] else [th [pcdata "Remove"]])
) :: voters)
in
let back = div [
a ~service:Web_services.election_setup [pcdata "Return to setup page"] uuid;
] in
let div_add =
if se.se_public_creds_received then
pcdata ""
else
div [
div [pcdata "Please enter the identities of voters to add, one per line:"];
form;
div [
b [pcdata "Note:"];
pcdata " An identity is either an e-mail address, or \"address,login\",";
pcdata " where \"address\" is an e-mail address and \"login\" the";
pcdata " associated login for authentication.";
];
]
in
let content = [
voters;
back;
div [pcdata "Please enter the identities of voters to add, one per line:"];
form;
div [
b [pcdata "Note:"];
pcdata " An identity is either an e-mail address, or \"address,login\",";
pcdata " where \"address\" is an e-mail address and \"login\" the";
pcdata " associated login for authentication.";
];
div_add;
] in
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