Commit 2965e0b2 authored by Stephane Glondu's avatar Stephane Glondu

Proper form for election_regenpwd

parent 39406edd
......@@ -63,7 +63,8 @@ let election_setup_auth_genpwd = post_coservice ~fallback:election_setup ~post_p
let election_home = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "")) ()
let election_admin = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "admin")) ()
let election_regenpwd = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "regenpwd") (string "user")) ()
let election_regenpwd = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "regenpwd")) ()
let election_regenpwd_post = post_coservice ~fallback:election_regenpwd ~post_params:(string "user") ()
let election_login = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "login") (opt (string "service"))) ()
let election_open = post_coservice ~fallback:election_admin ~post_params:unit ()
let election_close = post_coservice ~fallback:election_admin ~post_params:unit ()
......
......@@ -528,7 +528,13 @@ let () =
let () =
Any.register
~service:election_regenpwd
(fun ((uuid, ()), user) () ->
(fun (uuid, ()) user ->
T.regenpwd uuid () >>= Html5.send)
let () =
Any.register
~service:election_regenpwd_post
(fun (uuid, ()) user ->
let uuid_s = Uuidm.to_string uuid in
let w = SMap.find uuid_s !election_table in
let module W = (val w : WEB_ELECTION) in
......
......@@ -996,6 +996,9 @@ let election_admin w state () =
div [
a ~service:election_missing_voters [pcdata "Missing voters"] (uuid, ());
];
div [
a ~service:election_regenpwd [pcdata "Regenerate and mail a password"] (uuid, ());
];
div [state_div];
] in
lwt login_box = site_login_box () in
......@@ -1042,6 +1045,23 @@ let update_credential w () =
lwt login_box = site_login_box () in
base ~title:params.e_name ~login_box ~content ()
let regenpwd uuid () =
let form = post_form ~service:election_regenpwd_post
(fun user ->
[
div [
pcdata "Username: ";
string_input ~name:user ~input_type:`Text ();
];
div [string_input ~input_type:`Submit ~value:"Submit" ()];
]
) (uuid, ())
in
let content = [ form ] in
let title = "Regenerate and mail password" in
lwt login_box = site_login_box () in
base ~title ~login_box ~content ()
let cast_raw w () =
let module W = (val w : WEB_ELECTION) in
let params = W.election.e_params in
......
......@@ -39,6 +39,7 @@ val election_setup_trustee : string -> string -> Web_common.setup_election -> un
val election_home : (module WEB_ELECTION) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_admin : (module WEB_ELECTION) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val update_credential : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val regenpwd : Uuidm.t -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_raw : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmation : (module WEB_ELECTION) -> string -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmed : (module WEB_ELECTION) -> result:[< `Error of Web_common.error | `Valid of string ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
......
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