lidongdong
2022-10-08 53e9765219ea5e885393dc9c02ee0c46cc42ae08
修改小程序token
1个文件已修改
24 ■■■■ 已修改文件
flower_city/src/main/java/com/dg/core/interceptor/AuthorizationInterceptor.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flower_city/src/main/java/com/dg/core/interceptor/AuthorizationInterceptor.java
@@ -86,18 +86,20 @@
            }
        }
        //如果验证token失败,并且方法或类注明了Authorization,返回401错误
        if (method.getAnnotation(Authorization.class) != null ||
                bean.getClass().getAnnotation(Authorization.class) != null)
        if(!StringUtils.isEmpty(token))
        {
            String reponse = "{\"result\": 449, \"message\": \"Overdue token\"}";
            response.setStatus(200);
            response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
            ResponseFacade facade = (ResponseFacade) response;
            facade.setContentLength(reponse.getBytes(StandardCharsets.UTF_8).length);
            facade.getWriter().write(reponse);
            return false;
            //如果验证token失败,并且方法或类注明了Authorization,返回401错误
            if (method.getAnnotation(Authorization.class) != null ||
                    bean.getClass().getAnnotation(Authorization.class) != null)
            {
                String reponse = "{\"result\": 449, \"message\": \"Overdue token\"}";
                response.setStatus(200);
                response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
                ResponseFacade facade = (ResponseFacade) response;
                facade.setContentLength(reponse.getBytes(StandardCharsets.UTF_8).length);
                facade.getWriter().write(reponse);
                return false;
            }
        }
        return true;
    }