Commit b785f4aa authored by Stephane Glondu's avatar Stephane Glondu

Add possibility to define the server e-mail address in config

parent 3689ea16
......@@ -38,6 +38,7 @@
</site>
<eliom module="_build/src/web/server.cma">
<maxmailsatonce value="1000"/>
<server mail="noreply@belenios.org"/>
<auth name="demo"><dummy/></auth>
<auth name="local"><password db="demo/password_db.csv"/></auth>
<!-- <auth name="google"><oidc server="https://accounts.google.com" client_id="client-id" client_secret="client-secret"/></auth> -->
......
......@@ -27,6 +27,7 @@ open Web_serializable_builtin_t
open Web_serializable_j
let spool_dir = ref "."
let server_mail = ref "noreply@belenios.org"
module LwtRandom = struct
......@@ -197,7 +198,7 @@ let underscorize x =
let send_email recipient subject body =
let contents =
Netsendmail.compose
~from_addr:("Belenios public server", "noreply@belenios.org")
~from_addr:("Belenios public server", !server_mail)
~to_addrs:[recipient, recipient]
~in_charset:`Enc_utf8 ~out_charset:`Enc_utf8
~subject body
......@@ -229,3 +230,11 @@ let string_of_languages xs =
let languages_of_string x =
Pcre.split x
let email_rex = Pcre.regexp
~flags:[`CASELESS]
"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,7}$"
let is_email x =
try ignore (Pcre.pcre_exec ~rex:email_rex x); true
with Not_found -> false
......@@ -23,6 +23,7 @@ open Signatures
open Web_serializable_t
val spool_dir : string ref
val server_mail : string ref
module LwtRandom : RANDOM with type 'a t = 'a Lwt.t
(** Lwt-compatible random number generation. *)
......@@ -98,3 +99,5 @@ val available_languages : string list
val get_languages : string list option -> string list
val string_of_languages : string list option -> string
val languages_of_string : string -> string list
val is_email : string -> bool
......@@ -49,6 +49,11 @@ let () =
source_file := Some file
| Element ("maxmailsatonce", ["value", limit], []) ->
Web_site.maxmailsatonce := int_of_string limit
| Element ("server", ["mail", mail], []) ->
if is_email mail then
server_mail := mail
else
Printf.ksprintf failwith "%s is not a valid e-mail address" mail
| Element ("spool", ["dir", dir], []) ->
spool_dir := Some dir
| Element ("rewrite-prefix", ["src", src; "dst", dst], []) ->
......
......@@ -635,14 +635,6 @@ let is_identity x =
try ignore (Pcre.pcre_exec ~rex:identity_rex x); true
with Not_found -> false
let email_rex = Pcre.regexp
~flags:[`CASELESS]
"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,7}$"
let is_email x =
try ignore (Pcre.pcre_exec ~rex:email_rex x); true
with Not_found -> false
module SSet = Set.Make (PString)
let merge_voters a b f =
......
......@@ -1615,7 +1615,7 @@ let election_admin election metadata state get_tokens_decrypt () =
~absolute:true ~service x
in
let link_content, dest = match name with
| None -> uri, "toto@example.org"
| None -> uri, !server_mail
| Some name -> name, name
in
tr [
......
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