Send email with change game password link

O01eg
Apr 13, 2022, 11:08 AM
ZRU62WXDVY32ZF7AUYONXUQUAKZZGCUFWAYYBA32OXEBARVDVSNAC

Dependencies

  • [2] NLEIFOAG Add dependency to send mails
  • [3] I6SOPEQF Create and store reset password token
  • [4] BCXEUKX6 Add config, static files and web server
  • [5] ZE5UFPX4 Add TTL cache for CSRF
  • [6] CMA5SKJ3 Copy turns Atom generator
  • [7] WVHXYKCV Add postgresql pools
  • [8] Z3SYSC25 Add SMTP configuration
  • [9] 3HT5CE6S Manage TTL duration in config
  • [*] HZDCKIXQ Use constants for templates
  • [*] WLWTNO4Y Create form to request game password change link
  • [*] EVP2FSBH Split index page
  • [*] 4MZ4VIR7 Initial commit
  • [*] IM5ZPD4N Update dependencies

Change contents

  • edit in src/pages/query_reset_game_pwd.rs at line 48
    [12.1524]
    [12.1524]
    async fn send_email(
    mailer: &lettre::AsyncSmtpTransport<lettre::Tokio1Executor>,
    mailer_from: &lettre::message::Mailbox,
    token_url: String,
    to: &str,
    ) -> Result<(), Box<dyn std::error::Error>> {
    let email = lettre::Message::builder()
    .from(mailer_from.clone())
    .to(to.parse()?)
    .subject("FreeOrion reset game password link")
    .body(format!(
    "You requested change for FreeOrion game password.\n\
    Use next link {} to enter new password. Link is active for 24 hours.\n\
    Don't send it to other people.",
    token_url
    ))?;
    use lettre::AsyncTransport;
    mailer.send(email).await?;
    Ok(())
    }
  • edit in src/pages/query_reset_game_pwd.rs at line 159
    [3.1305]
    [12.1696]
    if let Err(e) = send_email(&data.mailer, &data.mailer_from, token_url, &form.contact).await {
    log::error!("Cann't send email: {}", e);
    return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
    }
  • edit in src/pages/mod.rs at line 33
    [4.47]
    [4.559]
    pub mailer: lettre::AsyncSmtpTransport<lettre::Tokio1Executor>,
    pub mailer_from: lettre::message::Mailbox,
  • edit in src/main.rs at line 49
    [4.3618]
    [4.856]
    mail,
  • edit in src/main.rs at line 52
    [4.912][4.0:11]()
    ..
  • edit in src/main.rs at line 110
    [4.3899]
    [4.1801]
    let smtp_credentials =
    lettre::transport::smtp::authentication::Credentials::new(mail.login, mail.passwd);
  • edit in src/main.rs at line 124
    [4.3918]
    [4.1899]
    mailer: lettre::AsyncSmtpTransport::<lettre::Tokio1Executor>::relay(&mail.server)
    .expect("Mail relay server")
    .credentials(smtp_credentials)
    .build(),
    mailer_from: lettre::message::Mailbox::new(
    None,
    mail.from
    .parse::<lettre::address::Address>()
    .expect("Mail from address"),
    ),
  • replacement in Cargo.toml at line 38
    [2.71][2.71:134]()
    features = ["hostname", "tokio1-rustls-tls", "smtp-transport"]
    [2.71]
    [2.134]
    features = ["hostname", "tokio1", "tokio1-rustls-tls", "smtp-transport", "builder"]
  • edit in Cargo.lock at line 534
    [4.19209]
    [4.19209]
    name = "email-encoding"
    version = "0.1.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "6690291166824e467790ac08ba42f241791567e8337bbf00c5a6e87889629f98"
    dependencies = [
    "base64",
    ]
    [[package]]
  • edit in Cargo.lock at line 577
    [4.4002]
    [15.5313]
    name = "fastrand"
    version = "1.7.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
    dependencies = [
    "instant",
    ]
    [[package]]
  • edit in Cargo.lock at line 938
    [2.1041]
    [2.1041]
    "email-encoding",
    "fastrand",
  • edit in Cargo.lock at line 943
    [2.1086]
    [2.1086]
    "httpdate",
  • edit in Cargo.lock at line 945
    [2.1095]
    [2.1095]
    "mime",
  • edit in Cargo.lock at line 948
    [2.1117]
    [2.1117]
    "quoted_printable",
  • edit in Cargo.lock at line 1372
    [4.30376]
    [4.30376]
    name = "quoted_printable"
    version = "0.4.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f"
    [[package]]