Commit ff4bb45e authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move do_log{in,out} out of AUTH_SERVICES

Rationale: we don't want templates to be able to call them.
parent 6b9be734
......@@ -116,13 +116,17 @@ module Make (N : CONFIG) = struct
~get_params:Eliom_parameter.(opt (string "service"))
()
let do_login cont () = login_handler None cont
let logout = Eliom_service.service
~path:(N.path @ ["logout"])
~get_params:Eliom_parameter.unit
()
end
module Handlers : AUTH_HANDLERS_PUBLIC = struct
let do_login cont () = login_handler None cont
let do_logout cont () =
match_lwt Eliom_reference.get user with
| Some u ->
......@@ -136,7 +140,7 @@ module Make (N : CONFIG) = struct
end
module Register (S : SITE_SERVICES) (T : TEMPLATES) : EMPTY = struct
module Register (S : SITE) (T : TEMPLATES) : EMPTY = struct
let () = login_choose := T.login_choose
......@@ -177,7 +181,7 @@ module Make (N : CONFIG) = struct
~service:Services.logout
(fun () () ->
lwt cont = Eliom_reference.get S.cont in
Services.do_logout cont ()
Handlers.do_logout cont ()
)
end
......
......@@ -41,5 +41,6 @@ end
module Make (C : CONFIG) : sig
module Services : AUTH_SERVICES
module Register (S : SITE_SERVICES) (T : TEMPLATES) : EMPTY
module Handlers : AUTH_HANDLERS_PUBLIC
module Register (S : SITE) (T : TEMPLATES) : EMPTY
end
......@@ -46,7 +46,7 @@ let can_vote m user =
module type REGISTRATION = sig
module W : WEB_ELECTION
module Register (S : SITE_SERVICES) (T : ELECTION_TEMPLATES) : EMPTY
module Register (S : SITE) (T : ELECTION_TEMPLATES) : EMPTY
end
let make {raw_election; metadata; featured; params_fname; public_keys_fname} =
......@@ -292,7 +292,7 @@ let make {raw_election; metadata; featured; params_fname; public_keys_fname} =
end
module Register (S : SITE_SERVICES) (T : ELECTION_TEMPLATES) : EMPTY = struct
module Register (S : SITE) (T : ELECTION_TEMPLATES) : EMPTY = struct
open Eliom_registration
let if_eligible acl f () x =
......
......@@ -27,7 +27,7 @@ open Web_signatures
module type REGISTRATION = sig
module W : WEB_ELECTION
module Register (S : SITE_SERVICES) (T : ELECTION_TEMPLATES) : EMPTY
module Register (S : SITE) (T : ELECTION_TEMPLATES) : EMPTY
end
val make : election_config -> (module REGISTRATION)
......@@ -156,6 +156,11 @@ module type AUTH_HANDLERS = sig
val logout : unit service_cont
end
module type AUTH_HANDLERS_PUBLIC = sig
val do_login : unit service_cont
val do_logout : unit service_cont
end
module type AUTH_SERVICES = sig
val get_auth_systems : unit -> string list
......@@ -180,9 +185,6 @@ module type AUTH_SERVICES = sig
[< Eliom_service.registrable > `Registrable ], 'a)
Eliom_service.service
val do_login : unit service_cont
val do_logout : unit service_cont
end
module type WEB_BALLOT_BOX = sig
......@@ -247,12 +249,14 @@ end
module type SITE_SERVICES = sig
include CORE_SERVICES
include AUTH_SERVICES
end
module type SITE = sig
include SITE_SERVICES
include AUTH_HANDLERS_PUBLIC
val register_election : election_config -> (module WEB_ELECTION) Lwt.t
val set_main_election : (module WEB_ELECTION) -> unit
val unset_main_election : unit -> unit
val cont : (unit -> service_handler) Eliom_reference.eref
end
......
......@@ -34,7 +34,7 @@ module type CONFIG = sig
val instances : Web_auth.auth_instance list
end
module Make (C : CONFIG) : SITE_SERVICES = struct
module Make (C : CONFIG) : SITE = struct
open Eliom_service
open Eliom_registration
......@@ -55,8 +55,9 @@ module Make (C : CONFIG) : SITE_SERVICES = struct
and Web_election. S is not meant to leak and will be included
in the returned module later. *)
module S : SITE_SERVICES = struct
module S : SITE = struct
include Auth.Services
include Auth.Handlers
open Eliom_parameter
let scope = Eliom_common.default_session_scope
......
......@@ -28,4 +28,4 @@ module type CONFIG = sig
val instances : Web_auth.auth_instance list
end
module Make (C : CONFIG) : SITE_SERVICES
module Make (C : CONFIG) : SITE
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