aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/core/accounts.rs18
-rw-r--r--src/api/core/global_domains.json3
-rw-r--r--src/mail.rs37
-rw-r--r--src/main.rs1
4 files changed, 26 insertions, 33 deletions
diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs
index 009269d9..8d6b7f15 100644
--- a/src/api/core/accounts.rs
+++ b/src/api/core/accounts.rs
@@ -5,7 +5,6 @@ use db::models::*;
use api::{PasswordData, JsonResult, EmptyResult, JsonUpcase, NumberOrString};
use auth::Headers;
-use fast_chemail::is_valid_email;
use mail;
use CONFIG;
@@ -329,22 +328,17 @@ struct PasswordHintData {
fn password_hint(data: JsonUpcase<PasswordHintData>, conn: DbConn) -> EmptyResult {
let data: PasswordHintData = data.into_inner().data;
- if !is_valid_email(&data.Email) {
- err!("This email address is not valid...");
- }
-
- let user = User::find_by_mail(&data.Email, &conn);
- if user.is_none() {
- return Ok(());
- }
+ let hint = match User::find_by_mail(&data.Email, &conn) {
+ Some(user) => user.password_hint,
+ None => return Ok(()),
+ };
- let user = user.unwrap();
if let Some(ref mail_config) = CONFIG.mail {
- if let Err(e) = mail::send_password_hint(&user.email, user.password_hint, mail_config) {
+ if let Err(e) = mail::send_password_hint(&data.Email, hint, mail_config) {
err!(format!("There have been a problem sending the email: {}", e));
}
} else if CONFIG.show_password_hint {
- if let Some(hint) = user.password_hint {
+ if let Some(hint) = hint {
err!(format!("Your password hint is: {}", &hint));
} else {
err!("Sorry, you have no password hint...");
diff --git a/src/api/core/global_domains.json b/src/api/core/global_domains.json
index 5a50023a..5eb50793 100644
--- a/src/api/core/global_domains.json
+++ b/src/api/core/global_domains.json
@@ -260,7 +260,8 @@
"Type": 26,
"Domains": [
"steampowered.com",
- "steamcommunity.com"
+ "steamcommunity.com",
+ "steamgames.com"
],
"Excluded": false
},
diff --git a/src/mail.rs b/src/mail.rs
index 81e23282..cb50e364 100644
--- a/src/mail.rs
+++ b/src/mail.rs
@@ -1,4 +1,3 @@
-use std::error::Error;
use native_tls::{Protocol, TlsConnector};
use lettre::{Transport, SmtpTransport, SmtpClient, ClientTlsParameters, ClientSecurity};
use lettre::smtp::ConnectionReuseParameters;
@@ -9,25 +8,24 @@ use MailConfig;
fn mailer(config: &MailConfig) -> SmtpTransport {
let client_security = if config.smtp_ssl {
- let mut tls_builder = TlsConnector::builder();
- tls_builder.min_protocol_version(Some(Protocol::Tlsv11));
- ClientSecurity::Required(
- ClientTlsParameters::new(config.smtp_host.to_owned(), tls_builder.build().unwrap())
- )
+ let tls = TlsConnector::builder()
+ .min_protocol_version(Some(Protocol::Tlsv11))
+ .build()
+ .unwrap();
+
+ ClientSecurity::Required(ClientTlsParameters::new(config.smtp_host.clone(), tls))
} else {
ClientSecurity::None
};
let smtp_client = SmtpClient::new(
- (config.smtp_host.to_owned().as_str(), config.smtp_port),
- client_security
+ (config.smtp_host.as_str(), config.smtp_port),
+ client_security,
).unwrap();
let smtp_client = match (&config.smtp_username, &config.smtp_password) {
- (Some(username), Some(password)) => {
- smtp_client.credentials(Credentials::new(username.to_owned(), password.to_owned()))
- },
- (_, _) => smtp_client,
+ (Some(user), Some(pass)) => smtp_client.credentials(Credentials::new(user.clone(), pass.clone())),
+ _ => smtp_client,
};
smtp_client
@@ -46,18 +44,19 @@ pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConf
hint))
} else {
("Sorry, you have no password hint...",
- "Sorry, you have not specified any password hint...\n".to_string())
+ "Sorry, you have not specified any password hint...\n".into())
};
let email = EmailBuilder::new()
.to(address)
- .from((config.smtp_from.to_owned(), "Bitwarden-rs"))
+ .from((config.smtp_from.clone(), "Bitwarden-rs"))
.subject(subject)
.body(body)
- .build().unwrap();
+ .build()
+ .map_err(|e| e.to_string())?;
- match mailer(config).send(email.into()) {
- Ok(_) => Ok(()),
- Err(e) => Err(e.description().to_string()),
- }
+ mailer(config)
+ .send(email.into())
+ .map_err(|e| e.to_string())
+ .and(Ok(()))
}
diff --git a/src/main.rs b/src/main.rs
index 34664364..a53f5a43 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,6 @@ extern crate num_traits;
extern crate lettre;
extern crate lettre_email;
extern crate native_tls;
-extern crate fast_chemail;
extern crate byteorder;
use std::{path::Path, process::{exit, Command}};