Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

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

More precise acl type and anonymous eligibility message

parent 45f8a1c8
{"readers":["Any"],"voters":["Any"]}
{"readers":"Any","voters":"Any"}
......@@ -157,14 +157,14 @@ let empty_metadata = {
let check_acl a u =
match a with
| Some acls ->
| Some `Any -> true
| Some (`Many items) ->
let rec loop = function
| [] -> false
| `Any :: _ -> true
| `Domain x :: _ when x = u.user_domain -> true
| `User x :: _ when x = u -> true
| _ :: xs -> loop xs
in loop acls
in loop items
| _ -> false
let uuid = Eliom_parameter.user_type
......
......@@ -68,7 +68,7 @@ val set_rewrite_prefix : src:string -> dst:string -> unit
val empty_metadata : metadata
val check_acl : acl list option -> user -> bool
val check_acl : acl option -> user -> bool
type election_file =
| ESRaw
......
......@@ -31,18 +31,18 @@ open Web_common
let can_read m user =
match m.e_readers with
| None -> false
| Some acls ->
| Some acl ->
match user with
| None -> List.mem `Any acls (* readers can be anonymous *)
| Some u -> check_acl (Some acls) u
| None -> acl = `Any (* readers can be anonymous *)
| Some u -> check_acl (Some acl) u
let can_vote m user =
match m.e_voters with
| None -> false
| Some acls ->
| Some acl ->
match user with
| None -> false (* voters must log in *)
| Some u -> check_acl (Some acls) u
| Some u -> check_acl (Some acl) u
module type REGISTRATION = sig
module W : WEB_ELECTION
......
......@@ -37,17 +37,21 @@ type user = {
name : string;
} <ocaml field_prefix="user_">
type acl_item =
[ Domain of string
| User of user
]
type acl =
[ Any
| Domain of string
| User of user
| Many of acl_item list
]
type metadata = {
?voting_starts_at : datetime option;
?voting_ends_at : datetime option;
?readers : acl list option;
?voters : acl list option;
?readers : acl option;
?voters : acl option;
?owner: user option;
} <ocaml field_prefix="e_">
......
......@@ -226,11 +226,22 @@ module Make (S : SITE_SERVICES) : TEMPLATES = struct
lwt permissions =
match user with
| None ->
Lwt.return [
pcdata "Log in to check if you can vote. ";
pcdata "Alternatively, you can try to vote and ";
pcdata "log in at the last moment.";
]
(match m.e_voters with
| Some `Any ->
return [
pcdata "Anybody can vote in this election.";
]
| Some _ ->
return [
pcdata "Log in to check if you can vote. ";
pcdata "Alternatively, you can try to vote and ";
pcdata "log in at the last moment.";
]
| None ->
return [
pcdata "Currently, nobody can vote in this election.";
]
)
| Some u ->
let can = if check_acl m.e_voters u then "can" else "cannot" in
Lwt.return [
......
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