|
@@ -2,6 +2,7 @@ package com.ningdatech.kqapi.user.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
import com.ningdatech.basic.model.ApiResponse; |
|
|
import com.ningdatech.kqapi.common.constant.BizConst; |
|
|
import com.ningdatech.kqapi.common.constant.BizConst; |
|
|
import com.ningdatech.kqapi.common.util.StrPool; |
|
|
import com.ningdatech.kqapi.common.util.StrPool; |
|
|
import com.ningdatech.kqapi.security.constant.AuthConst; |
|
|
import com.ningdatech.kqapi.security.constant.AuthConst; |
|
@@ -31,6 +32,9 @@ public class UserAuthController { |
|
|
|
|
|
|
|
|
private final ObjectMapper objectMapper; |
|
|
private final ObjectMapper objectMapper; |
|
|
|
|
|
|
|
|
|
|
|
public static final ApiResponse<Void> LOGOUT_RET = ApiResponse.of(HttpStatus.UNAUTHORIZED.value(), "已退出登录"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/login/password", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) |
|
|
@PostMapping(value = "/login/password", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) |
|
|
@ApiOperation(value = "账号密码的登陆方式") |
|
|
@ApiOperation(value = "账号密码的登陆方式") |
|
|
@ApiImplicitParams({ |
|
|
@ApiImplicitParams({ |
|
@@ -70,8 +74,8 @@ public class UserAuthController { |
|
|
cookie.setPath(request.getContextPath() + "/"); |
|
|
cookie.setPath(request.getContextPath() + "/"); |
|
|
cookie.setMaxAge(AuthConst.SESSION_EXPIRED); |
|
|
cookie.setMaxAge(AuthConst.SESSION_EXPIRED); |
|
|
response.addCookie(cookie); |
|
|
response.addCookie(cookie); |
|
|
response.setStatus(HttpStatus.UNAUTHORIZED.value()); |
|
|
|
|
|
response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); |
|
|
|
|
|
|
|
|
response.setStatus(HttpStatus.OK.value()); |
|
|
|
|
|
response.getWriter().write(objectMapper.writeValueAsString(LOGOUT_RET)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |