微调
This commit is contained in:
@@ -90,4 +90,25 @@ public interface DeviceValidMessage {
|
||||
|
||||
String ENABLE_FORMAT_ERROR = "是否启用格式错误,请检查enable参数";
|
||||
|
||||
String ERR_SYS_ID_NOT_BLANK = "误差体系ID不能为空,请检查errSysId参数";
|
||||
|
||||
String ERR_SYS_DTLS_TYPE_NOT_BLANK = "电能质量检测指标类型不能为空,请检查errSysDtlsType参数";
|
||||
|
||||
String ERR_SYS_DTLS_TYPE_FORMAT_ERROR = "电能质量检测指标类型格式错误,请检查errSysDtlsType参数";
|
||||
|
||||
String START_VALUE_NOT_NULL = "起始值不能为空,请检查startValue参数";
|
||||
|
||||
String START_FLAG_NOT_NULL = "是否包含起始值不能为空,请检查startFlag参数";
|
||||
|
||||
String END_VALUE_NOT_NULL = "结束值不能为空,请检查endValue参数";
|
||||
|
||||
String END_FLAG_NOT_NULL = "是否包含结束值不能为空,请检查endFlag参数";
|
||||
|
||||
String CONDITION_TYPE_NOT_BLANK = "判断条件类型不能为空,请检查conditionType参数";
|
||||
|
||||
String ERROR_VALUE_FORMAT_ERROR = "误差值格式错误,请检查errorValue参数";
|
||||
|
||||
String MAX_ERROR_VALUE_NOT_NULL = "最大误差值不能为空,请检查maxErrorValue参数";
|
||||
|
||||
String ERROR_VALUE_TYPE_NOT_BLANK = "误差值类型不能为空,请检查errorValueType参数";
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -54,16 +53,23 @@ public class AuthGlobalFilter implements Filter, Ordered {
|
||||
filterChain.doFilter(req, res);
|
||||
} else {
|
||||
String tokenStr = req.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
if (StrUtil.isNotBlank(tokenStr)) {
|
||||
tokenStr = tokenStr.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
if (StrUtil.isBlank(tokenStr) || !tokenStr.startsWith(SecurityConstants.AUTHORIZATION_PREFIX)) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
return;
|
||||
}
|
||||
tokenStr = tokenStr.substring(SecurityConstants.AUTHORIZATION_PREFIX.length());
|
||||
try {
|
||||
if (StrUtil.isBlank(tokenStr) || !JwtUtil.verifyToken(tokenStr) || JwtUtil.isExpired(tokenStr)) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
res.sendRedirect("/admin/login");
|
||||
} else {
|
||||
filterChain.doFilter(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,5 +87,5 @@ public interface SystemValidMessage {
|
||||
|
||||
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误,请检查autoGenerate参数";
|
||||
|
||||
String TOKEN_VALID_ERROR = "token校验失败,请重新登录";
|
||||
String TOKEN_VALID_ERROR = "token校验失败";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user