Commit 39394af6 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move "cont" reference to Web_services

parent f8020dc2
......@@ -288,11 +288,11 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
Auth.register templates N.auth_config
let login service () =
lwt cont = Eliom_reference.get S.cont in
lwt cont = Eliom_reference.get Web_services.cont in
Auth.Handlers.do_login service cont ()
let logout () () =
lwt cont = Eliom_reference.get S.cont in
lwt cont = Eliom_reference.get Web_services.cont in
Auth.Handlers.do_logout cont ()
module T = T.Election (W)
......@@ -318,7 +318,7 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
(Eliom_service.preapply
election_home (W.election.e_params.e_uuid, ()))
in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
match_lwt Eliom_reference.get cast_confirmed with
| Some result ->
Eliom_reference.unset cast_confirmed >>
......@@ -359,7 +359,7 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
election_dir
(W.election.e_params.e_uuid, f))
in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
handle_pseudo_file () f
)
......@@ -403,7 +403,7 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
(Eliom_service.preapply
election_vote (W.election.e_params.e_uuid, ()))
in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in
Redirection.send
(Eliom_service.preapply
......@@ -455,7 +455,7 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
(Eliom_service.preapply
election_cast (W.election.e_params.e_uuid, ()))
in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
match_lwt Eliom_reference.get ballot with
| Some _ -> ballot_received user >>= Html5.send
| None -> T.cast_raw () >>= Html5.send
......@@ -477,7 +477,7 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
(Eliom_service.preapply
Web_services.election_cast (W.election.e_params.e_uuid, ()))
in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
Eliom_reference.set ballot (Some the_ballot) >>
match user with
| None -> W.H.do_login None cont ()
......
......@@ -23,6 +23,7 @@ open Eliom_service
open Eliom_service.Http
open Eliom_parameter
open Web_common
open Web_signatures
let home = service ~path:[""] ~get_params:unit ()
let admin = service ~path:["admin"] ~get_params:unit ()
......@@ -64,3 +65,8 @@ let election_cast = service ~path:["elections"] ~get_params:(suffix (uuid "uuid"
let election_cast_post = post_service ~fallback:election_cast ~post_params:(opt (string "encrypted_vote") ** opt (file "encrypted_vote_file")) ()
let election_cast_confirm = post_coservice ~csrf_safe:true ~fallback:election_cast ~post_params:unit ()
let election_dir = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** election_file "file")) ()
let scope = Eliom_common.default_session_scope
let cont : (unit -> service_handler) Eliom_reference.eref =
Eliom_reference.eref ~scope (fun () () -> Eliom_registration.Redirection.send home)
......@@ -181,7 +181,6 @@ module type SITE = sig
val add_featured_election : string -> unit Lwt.t
val remove_featured_election : string -> unit Lwt.t
val is_featured_election : string -> bool Lwt.t
val cont : (unit -> service_handler) Eliom_reference.eref
val install_authentication : auth_config list -> unit
end
......
......@@ -112,11 +112,6 @@ let delete_shallow_directory dir =
open Eliom_parameter
open Eliom_service.Http
let scope = Eliom_common.default_session_scope
let cont = Eliom_reference.eref ~scope
(fun () () -> Eliom_registration.Redirection.send home)
let import_election f = !import_election_ref f
let add_featured_election x =
......@@ -331,7 +326,7 @@ let delete_shallow_directory dir =
let () = Html5.register ~service:admin
(fun () () ->
let cont () () = Redirection.send admin in
Eliom_reference.set S.cont cont >>
Eliom_reference.set Web_services.cont cont >>
lwt elections =
match_lwt get_user () with
| None -> return []
......@@ -349,11 +344,11 @@ let delete_shallow_directory dir =
)
let login service () =
lwt cont = Eliom_reference.get S.cont in
lwt cont = Eliom_reference.get Web_services.cont in
Auth.Handlers.do_login service cont ()
let logout () () =
lwt cont = Eliom_reference.get S.cont in
lwt cont = Eliom_reference.get Web_services.cont in
Auth.Handlers.do_logout cont ()
let () = Any.register ~service:site_login login
......
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