REM:
1. 优化代码
2. 修改用户登录的响应消息
This commit is contained in:
chenlinghy 2020-09-03 16:15:45 +08:00
parent c47daeb5cb
commit 0d85576263
3 changed files with 7 additions and 11 deletions

View File

@ -79,11 +79,11 @@ public class AuthController {
.userName(mr.getMsgContent().getUserName()) .userName(mr.getMsgContent().getUserName())
.token(ret.getSecondParam()) .token(ret.getSecondParam())
.logTime(System.currentTimeMillis()) .logTime(System.currentTimeMillis())
.expireTime(System.currentTimeMillis() + expTime) .expireTime((System.currentTimeMillis() / 1000 / 60) + expTime)
.build(); .build();
rspInfo.setStatus(ErrorCode.ERR_OK.getCode()); rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[] {ErrorCode.ERR_OK.getMsg()}); rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
} }
@ -117,7 +117,7 @@ public class AuthController {
.build(); .build();
rspInfo.setStatus(err.getCode()); rspInfo.setStatus(err.getCode());
rspInfo.setMessage(new String[] {err.getMsg()}); rspInfo.setMessage(new String[]{err.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
} }

View File

@ -110,7 +110,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
if (findRet.isPresent()) { if (findRet.isPresent()) {
user = findRet.get(); user = findRet.get();
// token过期获取以前没有token创建一个新token // token过期或者以前没有token创建一个新token
if (tokenTimeout(user.getLastAccess()) || user.getToken().length() == 0) { if (tokenTimeout(user.getLastAccess()) || user.getToken().length() == 0) {
token = createUserToken(username); token = createUserToken(username);
// 移除过期的项 // 移除过期的项
@ -420,12 +420,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
user = userAccountMapper.getUserByToken(token); user = userAccountMapper.getUserByToken(token);
// 用户未登录或者已经注销 // 用户未登录或者已经注销
if (user == null) { if (user == null || user.getToken().length() == 0) {
return ErrorCode.ERR_LOGOUT;
}
// 用户未登录或者已经注销
if (user.getToken().length() == 0) {
return ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} }
} }

View File

@ -29,7 +29,8 @@ public class LoginReq {
@NotBlank(message = "userName 用户名不能为空", groups = ValidGroups.LogoutReqValid.class) @NotBlank(message = "userName 用户名不能为空", groups = ValidGroups.LogoutReqValid.class)
@Pattern(regexp = AuthConfigValue.MYSQL_REGEX_CHARS, @Pattern(regexp = AuthConfigValue.MYSQL_REGEX_CHARS,
flags = Pattern.Flag.CASE_INSENSITIVE, flags = Pattern.Flag.CASE_INSENSITIVE,
message = "userName 用户名存在非法字符串") message = "userName 用户名存在非法字符串",
groups = ValidGroups.LogoutReqValid.class)
private String userName; private String userName;
/** /**