Commit ad2ae79fe390ed1fdb0ffecddff79f54d31e3645

Authored by lifeontrip
1 parent 3cdd2e1a

fix(DEFECT-676): 修改账号锁定的提示信息

@@ -42,6 +42,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; @@ -42,6 +42,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
42 import org.thingsboard.server.common.data.exception.ThingsboardException; 42 import org.thingsboard.server.common.data.exception.ThingsboardException;
43 import org.thingsboard.server.common.data.yunteng.core.Result; 43 import org.thingsboard.server.common.data.yunteng.core.Result;
44 import org.thingsboard.server.common.data.yunteng.core.exception.ThingsKitException; 44 import org.thingsboard.server.common.data.yunteng.core.exception.ThingsKitException;
  45 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
45 import org.thingsboard.server.common.msg.tools.TbRateLimitsException; 46 import org.thingsboard.server.common.msg.tools.TbRateLimitsException;
46 import org.thingsboard.server.dao.exception.DataValidationException; 47 import org.thingsboard.server.dao.exception.DataValidationException;
47 import org.thingsboard.server.service.security.exception.AuthMethodNotSupportedException; 48 import org.thingsboard.server.service.security.exception.AuthMethodNotSupportedException;
@@ -199,7 +200,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand @@ -199,7 +200,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand
199 } else if (authenticationException instanceof DisabledException) { 200 } else if (authenticationException instanceof DisabledException) {
200 mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("User account is not active", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); 201 mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("User account is not active", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
201 } else if (authenticationException instanceof LockedException) { 202 } else if (authenticationException instanceof LockedException) {
202 - mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("User account is locked due to security policy", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); 203 + mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.ACCOUNT_LOCKED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
203 } else if (authenticationException instanceof JwtExpiredTokenException) { 204 } else if (authenticationException instanceof JwtExpiredTokenException) {
204 mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Token has expired", ThingsboardErrorCode.JWT_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED)); 205 mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Token has expired", ThingsboardErrorCode.JWT_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED));
205 } else if (authenticationException instanceof AuthMethodNotSupportedException) { 206 } else if (authenticationException instanceof AuthMethodNotSupportedException) {
@@ -11,6 +11,7 @@ public enum ErrorMessage { @@ -11,6 +11,7 @@ public enum ErrorMessage {
11 ACCOUNT_DISABLED(403002, "账号已禁用"), 11 ACCOUNT_DISABLED(403002, "账号已禁用"),
12 ACCESS_DENIED(403003, "拒绝访问"), 12 ACCESS_DENIED(403003, "拒绝访问"),
13 AUTHENTICATION_METHOD_NOT_SUPPORTED(403004, "authentication method not supported"), 13 AUTHENTICATION_METHOD_NOT_SUPPORTED(403004, "authentication method not supported"),
  14 + ACCOUNT_LOCKED(403002, "根据相关安全策略账号已锁定!"),
14 USERNAME_PASSWORD_INCORRECT(401001, "incorrect username or password"), 15 USERNAME_PASSWORD_INCORRECT(401001, "incorrect username or password"),
15 TOKEN_EXPIRED(401002, "token has expired"), 16 TOKEN_EXPIRED(401002, "token has expired"),
16 NONE_TENANT_ASSET(401003, "not current tenant asset"), 17 NONE_TENANT_ASSET(401003, "not current tenant asset"),