]> Untitled Git - lemmy.git/commitdiff
Convert emails to lowercase (fixes #2462) (#2463)
authorNutomic <me@nutomic.com>
Tue, 27 Sep 2022 16:02:04 +0000 (16:02 +0000)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2022 16:02:04 +0000 (12:02 -0400)
crates/api/src/local_user/reset_password.rs
crates/api/src/local_user/save_settings.rs
crates/api_crud/src/user/create.rs

index 14071cb6b222d921344fde0a4b3083a0b2631c34..dbf959e10b7af1d9941a31b9db6b40a9c7729d58 100644 (file)
@@ -21,7 +21,7 @@ impl Perform for PasswordReset {
     let data: &PasswordReset = self;
 
     // Fetch that email
-    let email = data.email.clone();
+    let email = data.email.to_lowercase();
     let local_user_view = blocking(context.pool(), move |conn| {
       LocalUserView::find_by_email(conn, &email)
     })
index e8a94ff60cc00ecc9d81c965362188a636122604..b3e49d487e748cc967c876f242caaf548b9c8b53 100644 (file)
@@ -42,7 +42,7 @@ impl Perform for SaveUserSettings {
     let display_name = diesel_option_overwrite(&data.display_name);
     let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id);
     let bot_account = data.bot_account;
-    let email_deref = data.email.as_deref().map(|e| e.to_owned());
+    let email_deref = data.email.as_deref().map(|e| e.to_lowercase());
     let email = diesel_option_overwrite(&email_deref);
 
     if let Some(Some(email)) = &email {
index 2d2fe66afcfe8af9ab4d2267468fc14936159eee..9529d8a5aa32d2b3782d497705e03df0485b0fd9 100644 (file)
@@ -137,7 +137,7 @@ impl PerformCrud for Register {
     // Create the local user
     let local_user_form = LocalUserForm {
       person_id: Some(inserted_person.id),
-      email: Some(data.email.as_deref().map(|s| s.to_owned())),
+      email: Some(data.email.as_deref().map(|s| s.to_lowercase())),
       password_encrypted: Some(data.password.to_string()),
       show_nsfw: Some(data.show_nsfw),
       email_verified: Some(false),