Commit 26dc4b74 authored by Stephane Glondu's avatar Stephane Glondu

I18n of mails

parent e1760c48
(**************************************************************************)
(* BELENIOS *)
(* *)
(* Copyright © 2012-2016 Inria *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Affero General Public License as *)
(* published by the Free Software Foundation, either version 3 of the *)
(* License, or (at your option) any later version, with the additional *)
(* exemption that compiling, linking, and/or using OpenSSL is allowed. *)
(* *)
(* This program is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)
(* Affero General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Affero General Public *)
(* License along with this program. If not, see *)
(* <http://www.gnu.org/licenses/>. *)
(**************************************************************************)
let password name username password url = Printf.sprintf
"You are listed as a voter for the election
%s
You will find below your login and password. To cast a vote, you will
also need a credential, sent in a separate email. Be careful,
passwords and credentials look similar but play different roles. You
will be asked to enter your credential before entering the voting
booth. Login and passwords are required once your ballot is ready to
be cast.
Username: %s
Password: %s
Page of the election: %s
Note that you are allowed to vote several times. Only the last vote
counts.
-- \nBelenios" name username password url
let credential name username cred url = Printf.sprintf
"You are listed as a voter for the election
%s
You will find below your login and credential. To cast a vote, you will
also need a password, sent in a separate email. Be careful,
passwords and credentials look similar but play different roles. You
will be asked to enter your credential before entering the voting
booth. Login and passwords are required once your ballot is ready to
be cast.
Username: %s
Credential: %s
Page of the election: %s
Note that you are allowed to vote several times. Only the last vote
counts.
-- \nBelenios" name username cred url
let confirmation id name hash ballots_url url = Printf.sprintf
"Dear %s,
Your vote for election
%s
has been recorded. Your smart ballot tracker is
%s
You can check its presence in the ballot box, accessible at
%s
Results will be published on the election page
%s
-- \nBelenios" id name hash ballots_url url
......@@ -21,7 +21,6 @@ Web_services
Web_state
Web_templates
Web_auth
Mail_templates
Web_election
Web_site
Web_main
......@@ -250,3 +250,5 @@ let split_identity x =
String.sub x 0 i, String.sub x (i+1) (n-i-1)
with Not_found ->
x, x
let langs = ["en"; "fr"]
......@@ -126,3 +126,5 @@ val underscorize : string -> string
val send_email : string -> string -> string -> unit Lwt.t
val split_identity : string -> string * string
val langs : string list
......@@ -61,7 +61,9 @@ module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELE
let url2 = Eliom_uri.make_string_uri ~absolute:true
~service:Web_services.election_home x |> rewrite_prefix
in
let body = Mail_templates.confirmation user title hash url1 url2 in
lwt language = Eliom_reference.get Web_state.language in
let module L = (val Web_i18n.get_lang language) in
let body = Printf.sprintf L.mail_confirmation user title hash url1 url2 in
send_email email subject body
let do_cast rawballot (user, date) =
......
......@@ -73,4 +73,7 @@ module type LocalizedStrings = sig
val password : string
val login : string
val password_login : string
val mail_password : (string -> string -> string -> string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
val mail_credential : (string -> string -> string -> string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
val mail_confirmation : (string -> string -> string -> string -> string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
end
......@@ -72,3 +72,65 @@ let username = "Username:"
let password = "Password:"
let login = "Login"
let password_login = "Password login"
let mail_password : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"You are listed as a voter for the election
%s
You will find below your login and password. To cast a vote, you will
also need a credential, sent in a separate email. Be careful,
passwords and credentials look similar but play different roles. You
will be asked to enter your credential before entering the voting
booth. Login and passwords are required once your ballot is ready to
be cast.
Username: %s
Password: %s
Page of the election: %s
Note that you are allowed to vote several times. Only the last vote
counts."
let mail_credential : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"You are listed as a voter for the election
%s
You will find below your login and credential. To cast a vote, you will
also need a password, sent in a separate email. Be careful,
passwords and credentials look similar but play different roles. You
will be asked to enter your credential before entering the voting
booth. Login and passwords are required once your ballot is ready to
be cast.
Username: %s
Credential: %s
Page of the election: %s
Note that you are allowed to vote several times. Only the last vote
counts."
let mail_confirmation : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"Dear %s,
Your vote for election
%s
has been recorded. Your smart ballot tracker is
%s
You can check its presence in the ballot box, accessible at
%s
Results will be published on the election page
%s
-- \nBelenios"
......@@ -72,3 +72,67 @@ let username = "Nom d'utilisateur :"
let password = "Mot de passe :"
let login = "Se connecter"
let password_login = "Connexion par mot de passe"
let mail_password : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"Vous êtes enregistré(e) en tant qu'électeur pour l'élection
%s
Veuillez trouver ci-dessous votre nom d'utilisateur et votre mot de
passe. Pour soumettre un bulletin, vous aurez également besoin d'un
code de vote, envoyé dans un e-mail séparé. Soyez prudent(e), le mot
de passe et le code de vote se ressemblent mais jouent des rôles
différents. Le système vous demandera votre code de vote dès l'entrée
dans l'isoloir virtuel. Le nom d'utilisateur et le mot de passe sont
nécessaires lorsque votre bulletin est prêt à être soumis.
Nom d'utilisateur : %s
Mot de passe : %s
Page de l'élection : %s
Notez que vous pouvez voter plusieurs fois. Seule la dernière est
prise en compte."
let mail_credential : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"Vous êtes enregistré(e) en tant qu'électeur pour l'élection
%s
Veuillez trouver ci-dessous votre nom d'utilisateur et votre code de
vote. Pour soumettre un bulletin, vous aurez également besoin d'un
mot de passe, envoyé dans un e-mail séparé. Soyez prudent(e), le mot
de passe et le code de vote se ressemblent mais jouent des rôles
différents. Le système vous demandera votre code de vote dès l'entrée
dans l'isoloir virtuel. Le nom d'utilisateur et le mot de passe sont
nécessaires lorsque votre bulletin est prêt à être soumis.
Nom d'utilisateur : %s
Code de vote : %s
Page de l'élection : %s
Notez que vous pouvez voter plusieurs fois. Seule la dernière est
prise en compte."
let mail_confirmation : ('a, 'b, 'c, 'd, 'e, 'f) format6 =
"%s,
Votre vote pour l'élection
%s
a été enregistré. Votre numéro de suivi est
%s
Vous pouvez vérifier sa présence dans l'urne, accessible au
%s
Les résultats seront publiés sur la page de l'élection
%s
-- \nBelenios"
......@@ -420,12 +420,17 @@ let () =
};
return (redir_preapply election_setup uuid)))
let generate_password title url id =
let generate_password langs title url id =
let email, login = split_identity id in
lwt salt = generate_token () in
lwt password = generate_token () in
let hashed = sha256_hex (salt ^ password) in
let body = Mail_templates.password title login password url in
let bodies = List.map (fun lang ->
let module L = (val Web_i18n.get_lang lang) in
Printf.sprintf L.mail_password title login password url
) langs in
let body = PString.concat "\n\n----------\n\n" bodies in
let body = body ^ "\n\n-- \nBelenios" in
let subject = "Your password for election " ^ title in
send_email email subject body >>
return (salt, hashed)
......@@ -439,7 +444,7 @@ let handle_password se uuid ~force voters =
match id.sv_password with
| Some _ when not force -> return_unit
| None | Some _ ->
lwt x = generate_password title url id.sv_id in
lwt x = generate_password langs title url id.sv_id in
return (id.sv_password <- Some x)
) voters >>
return (fun () ->
......@@ -481,7 +486,7 @@ let () =
let service = preapply election_admin (uuid, ()) in
begin try_lwt
lwt _ = Ocsipersist.find table user in
lwt x = generate_password title url user in
lwt x = generate_password langs title url user in
Ocsipersist.add table user x >>
dump_passwords (!spool_dir / uuid_s) table >>
T.generic_page ~title:"Success" ~service
......@@ -748,7 +753,12 @@ let () =
let y = G.(g **~ x) in
G.to_string y
in
let body = Mail_templates.credential title login cred url in
let bodies = List.map (fun lang ->
let module L = (val Web_i18n.get_lang lang) in
Printf.sprintf L.mail_credential title login cred url
) langs in
let body = PString.concat "\n\n----------\n\n" bodies in
let body = body ^ "\n\n-- \nBelenios" in
let subject = "Your credential for election " ^ title in
lwt () = send_email email subject body in
return @@ S.add pub_cred accu
......
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