1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-04 02:18:00 +01:00

validate billing_email on save

Dieser Commit ist enthalten in:
Stefan Melmuk 2022-10-25 22:21:22 +02:00 committet von Daniel García
Ursprung 31b77bf178
Commit 870f0d0932
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: FC8A7D14C3CD543A
3 geänderte Dateien mit 9 neuen und 0 gelöschten Zeilen

4
Cargo.lock generiert
Datei anzeigen

@ -699,6 +699,9 @@ name = "email_address"
version = "0.2.3" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1b32a7a2580c4473f10f66b512c34bdd7d33c5e3473227ca833abdb5afe4809" checksum = "b1b32a7a2580c4473f10f66b512c34bdd7d33c5e3473227ca833abdb5afe4809"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
@ -3162,6 +3165,7 @@ dependencies = [
"diesel", "diesel",
"diesel_migrations", "diesel_migrations",
"dotenvy", "dotenvy",
"email_address",
"fern", "fern",
"futures", "futures",
"governor", "governor",

Datei anzeigen

@ -110,6 +110,7 @@ url = "2.3.1"
# Email librariese-Base, Update crates and small change. # Email librariese-Base, Update crates and small change.
lettre = { version = "0.10.1", features = ["smtp-transport", "builder", "serde", "tokio1-native-tls", "hostname", "tracing", "tokio1"], default-features = false } lettre = { version = "0.10.1", features = ["smtp-transport", "builder", "serde", "tokio1-native-tls", "hostname", "tracing", "tokio1"], default-features = false }
percent-encoding = "2.2.0" # URL encoding library used for URL's in the emails percent-encoding = "2.2.0" # URL encoding library used for URL's in the emails
email_address = "0.2.3"
# Template library # Template library
handlebars = { version = "4.3.5", features = ["dir_source"] } handlebars = { version = "4.3.5", features = ["dir_source"] }

Datei anzeigen

@ -217,6 +217,10 @@ use crate::error::MapResult;
/// Database methods /// Database methods
impl Organization { impl Organization {
pub async fn save(&self, conn: &mut DbConn) -> EmptyResult { pub async fn save(&self, conn: &mut DbConn) -> EmptyResult {
if !email_address::EmailAddress::is_valid(self.billing_email.trim()) {
err!(format!("BillingEmail {} is not a valid email address", self.billing_email.trim()))
}
for user_org in UserOrganization::find_by_org(&self.uuid, conn).await.iter() { for user_org in UserOrganization::find_by_org(&self.uuid, conn).await.iter() {
User::update_uuid_revision(&user_org.user_uuid, conn).await; User::update_uuid_revision(&user_org.user_uuid, conn).await;
} }