Commit 6bacf24a authored by Stephane Glondu's avatar Stephane Glondu

Move mail templates to their own module

parent 3641d190
(**************************************************************************)
(* 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
......@@ -14,6 +14,7 @@ Web_services
Web_auth_state
Web_templates
Web_site_auth
Mail_templates
Web_election
Web_site
Web_main
......@@ -30,27 +30,6 @@ open Web_common
let ( / ) = Filename.concat
let template_confirmation = format_of_string
"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"
module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION = struct
let uuid = Uuidm.to_string D.election.e_params.e_uuid
......@@ -82,9 +61,7 @@ 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 = Printf.sprintf template_confirmation
user title hash url1 url2
in
let body = Mail_templates.confirmation user title hash url1 url2 in
send_email "noreply@belenios.org" email subject body
let do_cast rawballot (user, date) =
......
......@@ -415,34 +415,12 @@ let () =
};
return (redir_preapply election_setup uuid)))
let template_password = format_of_string
"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.
--
Belenios"
let generate_password 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 = Printf.sprintf template_password title login password url in
let body = Mail_templates.password title login password url in
let subject = "Your password for election " ^ title in
send_email "noreply@belenios.org" email subject body >>
return (salt, hashed)
......@@ -777,28 +755,6 @@ module Credgen = struct
end
let template_credential = format_of_string
"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.
--
Belenios"
let () =
Any.register
~service:election_setup_credentials_server
......@@ -825,7 +781,7 @@ let () =
let y = G.(g **~ x) in
G.to_string y
in
let body = Printf.sprintf template_credential title login cred url in
let body = Mail_templates.credential title login cred url in
let subject = "Your credential for election " ^ title in
lwt () = send_email "noreply@belenios.org" 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