mirror of
https://git.verdigado.com/NB-Public/simple-wkd.git
synced 2024-12-06 14:52:41 +01:00
Add a webpage
This commit is contained in:
parent
e621a735f5
commit
a91b213dbf
9 changed files with 107 additions and 47 deletions
|
@ -105,6 +105,13 @@ pub fn confirm_action(token: &str) -> Result<(Action, String), Error> {
|
|||
pub fn send_confirmation_email(address: &str, action: &Action, token: &str) -> Result<(), Error> {
|
||||
debug!("Sending email to {}", address);
|
||||
let template = fs::read_to_string(Path::new("assets").join("mail-template.html")).unwrap();
|
||||
let mut url = SETTINGS
|
||||
.external_url
|
||||
.join("api/")
|
||||
.unwrap()
|
||||
.join("confirm")
|
||||
.unwrap();
|
||||
url.set_query(Some(&format!("token={}", token)));
|
||||
let email = Message::builder()
|
||||
.from(match SETTINGS.mail_settings.mail_from.parse() {
|
||||
Ok(mailbox) => mailbox,
|
||||
|
@ -129,18 +136,7 @@ pub fn send_confirmation_email(address: &str, action: &Action, token: &str) -> R
|
|||
.header(ContentType::TEXT_HTML)
|
||||
.body(
|
||||
template
|
||||
.replace(
|
||||
"{{%u}}",
|
||||
SETTINGS
|
||||
.external_url
|
||||
.join("api/")
|
||||
.unwrap()
|
||||
.join("confirm/")
|
||||
.unwrap()
|
||||
.join(token)
|
||||
.unwrap()
|
||||
.as_ref(),
|
||||
)
|
||||
.replace("{{%u}}", url.as_ref())
|
||||
.replace("{{%a}}", &action.to_string().to_lowercase()),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue