Commit 9b4c7dc1 authored by Stephane Glondu's avatar Stephane Glondu Committed by Stéphane Glondu
Browse files

Add a configuration option to deny revotes

parent 60ec737f
Pipeline #332776 failed with stage
in 26 minutes and 37 seconds
......@@ -79,6 +79,12 @@
<admin-home file="_VARDIR_/admin-home.html"/>
<warning file="_VARDIR_/warning.html"/>
<footer file="_VARDIR_/footer.html"/>
<!--
Uncomment the following line to disable revoting. Note that
the ability to revote is important as a (light) measure
against coercion.
-->
<!-- <deny-revote/> -->
</eliom>
</host>
......
......@@ -38,3 +38,4 @@ let uuid_length = ref None
let default_group = ref ""
let nh_group = ref ""
let domain = ref ""
let deny_revote = ref false
......@@ -41,3 +41,4 @@ val uuid_length : int option ref
val default_group : string ref
val nh_group : string ref
val domain : string ref
val deny_revote : bool ref
......@@ -112,6 +112,8 @@ module Make () = struct
auth_instances_export := `Export i :: !auth_instances_export
| Element ("domain", ["name", name], []) ->
domain := Some name
| Element ("deny-revote", [], []) ->
Web_config.deny_revote := true
| Element (tag, _, _) ->
Printf.ksprintf failwith
"invalid configuration for tag %s in belenios"
......
......@@ -782,14 +782,18 @@ let do_cast_ballot election ~rawballot ~user ~weight date =
match x with
| Error _ as x -> return x
| Ok (credential, _, old) ->
let* hash, revote =
let@ hash, revote = fun cont ->
match old with
| None ->
let* h = add_ballot election rawballot in
return (h, false)
cont (h, false)
| Some hash ->
let* h = replace_ballot election ~hash ~rawballot in
return (h, true)
if !Web_config.deny_revote then (
return @@ Error `RevoteNotAllowed
) else (
let* h = replace_ballot election ~hash ~rawballot in
cont (h, true)
)
in
let* () = add_credential_mapping uuid credential (Some hash) in
let* () = add_extended_record uuid user (date, credential) in
......
Supports Markdown
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