]> Untitled Git - lemmy.git/blobdiff - crates/api/src/local_user/login.rs
Updating `login.rs` with generic `incorrect_login` response. (#3549)
[lemmy.git] / crates / api / src / local_user / login.rs
index 9f5e587443b40495740f88b7e8b23ef136bfa0de..3bf177666c2a5d7f90973cf6786213e4739a6e54 100644 (file)
@@ -23,7 +23,7 @@ impl Perform for Login {
     let username_or_email = data.username_or_email.clone();
     let local_user_view = LocalUserView::find_by_email_or_name(context.pool(), &username_or_email)
       .await
-      .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_that_username_or_email"))?;
+      .map_err(|e| LemmyError::from_error_message(e, "incorrect_login"))?;
 
     // Verify the password
     let valid: bool = verify(
@@ -32,7 +32,7 @@ impl Perform for Login {
     )
     .unwrap_or(false);
     if !valid {
-      return Err(LemmyError::from_message("password_incorrect"));
+      return Err(LemmyError::from_message("incorrect_login"));
     }
     check_user_valid(
       local_user_view.person.banned,
@@ -40,7 +40,11 @@ impl Perform for Login {
       local_user_view.person.deleted,
     )?;
 
-    if site_view.local_site.require_email_verification && !local_user_view.local_user.email_verified
+    // Check if the user's email is verified if email verification is turned on
+    // However, skip checking verification if the user is an admin
+    if !local_user_view.person.admin
+      && site_view.local_site.require_email_verification
+      && !local_user_view.local_user.email_verified
     {
       return Err(LemmyError::from_message("email_not_verified"));
     }