Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 8e86cbe9 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add a button to send again a password

parent de0ef68c
...@@ -44,7 +44,8 @@ let election_setup_questions_post = post_coservice ~fallback:election_setup_ques ...@@ -44,7 +44,8 @@ let election_setup_questions_post = post_coservice ~fallback:election_setup_ques
let election_setup_description = post_coservice ~fallback:election_setup ~post_params:(string "name" ** string "description") () let election_setup_description = post_coservice ~fallback:election_setup ~post_params:(string "name" ** string "description") ()
let election_setup_voters = service ~path:["setup"; "voters"] ~get_params:(uuid "uuid") () let election_setup_voters = service ~path:["setup"; "voters"] ~get_params:(uuid "uuid") ()
let election_setup_voters_add = post_service ~fallback:election_setup_voters ~post_params:(string "voters") () let election_setup_voters_add = post_service ~fallback:election_setup_voters ~post_params:(string "voters") ()
let election_setup_voters_remove = post_service ~fallback:election_setup_voters ~post_params:(string "voter") () let election_setup_voters_remove = post_coservice ~fallback:election_setup_voters ~post_params:(string "voter") ()
let election_setup_voters_passwd = post_coservice ~fallback:election_setup_voters ~post_params:(string "voter") ()
let election_setup_trustee_add = post_coservice ~fallback:election_setup ~post_params:unit () let election_setup_trustee_add = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_trustee_del = post_coservice ~fallback:election_setup ~post_params:unit () let election_setup_trustee_del = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_credential_authority = service ~path:["setup"; "credential-authority"] ~get_params:(uuid "uuid") () let election_setup_credential_authority = service ~path:["setup"; "credential-authority"] ~get_params:(uuid "uuid") ()
......
...@@ -498,26 +498,28 @@ let generate_password title url id = ...@@ -498,26 +498,28 @@ let generate_password title url id =
send_email "noreply@belenios.org" email subject body >> send_email "noreply@belenios.org" email subject body >>
return (salt, hashed) return (salt, hashed)
let handle_password se uuid ~force voters =
let title = se.se_questions.t_name in
let url = Eliom_uri.make_string_uri ~absolute:true ~service:election_home
(uuid, ()) |> rewrite_prefix
in
Lwt_list.iter_s (fun id ->
match id.sv_password with
| Some _ when not force -> return_unit
| None | Some _ ->
lwt x = generate_password title url id.sv_id in
return (id.sv_password <- Some x)
) voters >>
return (fun () ->
T.generic_page ~title:"Success"
"Passwords have been generated and mailed!" () >>= Html5.send)
let () = let () =
Any.register Any.register
~service:election_setup_auth_genpwd ~service:election_setup_auth_genpwd
(handle_setup (handle_setup
(fun se () _ uuid -> (fun se () _ uuid ->
let title = se.se_questions.t_name in handle_password se uuid ~force:false se.se_voters))
let url = Eliom_uri.make_string_uri
~absolute:true ~service:election_home
(uuid, ()) |> rewrite_prefix
in
Lwt_list.iter_s (fun id ->
match id.sv_password with
| None ->
lwt x = generate_password title url id.sv_id in
return (id.sv_password <- Some x)
| Some _ -> return_unit
) se.se_voters >>
return (fun () ->
T.generic_page ~title:"Success"
"Passwords have been generated and mailed!" () >>= Html5.send)))
let () = let () =
Any.register Any.register
...@@ -644,6 +646,13 @@ let () = ...@@ -644,6 +646,13 @@ let () =
) se.se_voters; ) se.se_voters;
return (redir_preapply election_setup_voters uuid)))) return (redir_preapply election_setup_voters uuid))))
let () =
Any.register ~service:election_setup_voters_passwd
(handle_setup
(fun se voter _ uuid ->
let voter = List.filter (fun v -> v.sv_id = voter) se.se_voters in
handle_password se uuid ~force:true voter))
let () = let () =
Redirection.register Redirection.register
~service:election_setup_trustee_add ~service:election_setup_trustee_add
......
...@@ -630,15 +630,25 @@ let election_setup_voters uuid se () = ...@@ -630,15 +630,25 @@ let election_setup_voters uuid se () =
| Some [{auth_system = "password"; _}] -> true | Some [{auth_system = "password"; _}] -> true
| _ -> false | _ -> false
in in
let to_string x = match x with let mk_regen_passwd value =
| Some _ -> "Yes" post_form ~service:election_setup_voters_passwd
| None -> "No" ~a:[a_style "display: inline;"]
(fun name ->
[
string_input ~input_type:`Hidden ~name ~value ();
string_input ~input_type:`Submit ~value:"Send again" ();
]
) uuid
in
let format_password_cell x = match x.sv_password with
| Some _ -> [pcdata "Yes "; mk_regen_passwd x.sv_id]
| None -> [pcdata "No"]
in in
let voters = let voters =
List.map (fun v -> List.map (fun v ->
tr ( tr (
[td [pcdata v.sv_id]] @ [td [pcdata v.sv_id]] @
(if has_passwords then [td [pcdata (to_string v.sv_password)]] else []) @ (if has_passwords then [td (format_password_cell v)] else []) @
(if se.se_public_creds_received then [] 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 ) se.se_voters
...@@ -660,7 +670,7 @@ let election_setup_voters uuid se () = ...@@ -660,7 +670,7 @@ let election_setup_voters uuid se () =
table table
(tr ( (tr (
[th [pcdata "Identity"]] @ [th [pcdata "Identity"]] @
(if has_passwords then [th [pcdata "Password"]] else []) @ (if has_passwords then [th [pcdata "Password sent?"]] else []) @
(if se.se_public_creds_received then [] else [th [pcdata "Remove"]]) (if se.se_public_creds_received then [] else [th [pcdata "Remove"]])
) :: voters) ) :: voters)
] ]
......
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