Skip to content

Commit

Permalink
fix: user is not exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrettluo committed Jul 27, 2024
1 parent 03eab94 commit 0932ffa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/com/jiaruiblog/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public BaseApiResult batchInsert(@RequestBody List<RegistryUserDTO> userDTOS) {
@PostMapping(value = "/getById")
public BaseApiResult getById(@RequestBody UserDTO user) {
User one = userService.queryById(user.getId());
// 增加对无效用户的判断
if (Objects.isNull(one)) {
return BaseApiResult.error(MessageConstant.PROCESS_ERROR_CODE, MessageConstant.DATA_IS_NULL);
}
return BaseApiResult.success(one);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jiaruiblog/filter/JwtFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
response.setCharacterEncoding("UTF-8");
String url = request.getRequestURI().substring(request.getContextPath().length());
// 登录和注册等请求不需要令牌
if (url.contains("login") || url.contains("register") || url.contains("files")) {
if (url.contains("login") || url.contains("/user/insert") || url.contains("files")) {
response.setStatus(HttpServletResponse.SC_OK);
chain.doFilter(request, response);
return;
Expand Down

0 comments on commit 0932ffa

Please sign in to comment.