You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2025/10/10 11:17:37 UTC

(iotdb) branch master updated: fix login locked error message (#16550)

This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a25d725313 fix login locked error message (#16550)
9a25d725313 is described below

commit 9a25d72531383122a2acfeaf6b6a24b1a401a15a
Author: Hongzhi Gao <76...@qq.com>
AuthorDate: Fri Oct 10 19:17:31 2025 +0800

    fix login locked error message (#16550)
    
    * fix login locked error message
    
    * fix login locked error message
    
    * fix RelationalSql.g4 alter user account unlock
---
 .../src/main/java/org/apache/iotdb/rpc/TSStatusCode.java |  1 +
 .../java/org/apache/iotdb/db/auth/LoginLockManager.java  |  9 +++++++++
 .../apache/iotdb/db/protocol/session/SessionManager.java |  4 ++--
 .../iotdb/db/relational/grammar/sql/RelationalSql.g4     | 16 ++--------------
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
index 98f05176068..b19221e1b80 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
@@ -171,6 +171,7 @@ public enum TSStatusCode {
   AUTH_OPERATE_EXCEPTION(818),
   OPTIMIZER_TIMEOUT(819),
   ILLEGAL_PASSWORD(820),
+  USER_LOGIN_LOCKED(822),
 
   // Partition Error
   MIGRATE_REGION_ERROR(900),
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/LoginLockManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/LoginLockManager.java
index 51ecb9ad825..66dbc8a7c8a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/LoginLockManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/LoginLockManager.java
@@ -165,6 +165,15 @@ public class LoginLockManager {
     return false;
   }
 
+  /**
+   * Returns the number of consecutive failed login attempts.
+   *
+   * @return the number of failed login attempts
+   */
+  public int getFailedLoginAttempts() {
+    return failedLoginAttempts;
+  }
+
   /**
    * Record a failed login attempt
    *
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/session/SessionManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/session/SessionManager.java
index e2f88bb8076..570e53374f0 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/session/SessionManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/session/SessionManager.java
@@ -145,8 +145,8 @@ public class SessionManager implements SessionManagerMBean {
       // Generic authentication error
       openSessionResp
           .sessionId(-1)
-          .setMessage("Authentication failed.")
-          .setCode(TSStatusCode.WRONG_LOGIN_PASSWORD.getStatusCode());
+          .setMessage("Account is blocked due to consecutive failed logins.")
+          .setCode(TSStatusCode.USER_LOGIN_LOCKED.getStatusCode());
       return openSessionResp;
     }
 
diff --git a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4 b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
index a17932b4380..59231b6de2b 100644
--- a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
+++ b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
@@ -720,7 +720,7 @@ usernameWithRoot
     ;
 
 usernameWithRootWithOptionalHost
-    : usernameWithRoot (AT host=STRING_LITERAL)?
+    : usernameWithRoot (AT_SIGN host=string)?
     ;
 
 renameUserStatement
@@ -1822,6 +1822,7 @@ YEAR: 'YEAR' | 'Y';
 ZONE: 'ZONE';
 AUDIT: 'AUDIT';
 
+AT_SIGN: '@';
 EQ: '=';
 NEQ: '<>' | '!=';
 LT: '<';
@@ -1897,19 +1898,6 @@ fragment DATE_LITERAL
     | INTEGER_VALUE '.' INTEGER_VALUE '.' INTEGER_VALUE
     ;
 
-fragment DQUOTA_STRING
-    : '"' ( '""' | ~('"') )* '"'
-    ;
-
-fragment SQUOTA_STRING
-    : '\'' ( '\'\'' | ~('\'') )* '\''
-    ;
-
-STRING_LITERAL
-    : DQUOTA_STRING
-    | SQUOTA_STRING
-    ;
-
 fragment TIME_LITERAL
     : INTEGER_VALUE ':' INTEGER_VALUE ':' INTEGER_VALUE ('.' INTEGER_VALUE)?
     ;