build: 退出登录的接口检查是否有用户

This commit is contained in:
CaptainB 2023-09-19 12:31:28 +08:00 committed by 刘瑞斌
parent 4a531c2334
commit ebd651ea94
1 changed files with 4 additions and 1 deletions

View File

@ -85,7 +85,10 @@ public class LoginController {
@GetMapping(value = "/signout") @GetMapping(value = "/signout")
@Operation(summary = "退出登录") @Operation(summary = "退出登录")
public ResultHolder logout(HttpServletResponse response) throws Exception { public ResultHolder logout() throws Exception {
if (SessionUtils.getUser() == null) {
return ResultHolder.success("logout success");
}
baseUserService.saveLog(SessionUtils.getUserId(), HttpMethodConstants.GET.name(), "/signout", "登出成功", OperationLogType.LOGOUT.name()); baseUserService.saveLog(SessionUtils.getUserId(), HttpMethodConstants.GET.name(), "/signout", "登出成功", OperationLogType.LOGOUT.name());
SecurityUtils.getSubject().logout(); SecurityUtils.getSubject().logout();
return ResultHolder.success("logout success"); return ResultHolder.success("logout success");