登录相关返回结果修改
This commit is contained in:
parent
d5a1803a7f
commit
92b0a0ccb4
@ -1,5 +1,7 @@
|
|||||||
package com.macro.mall.portal.component;
|
package com.macro.mall.portal.component;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ public class GoAccessDeniedHandler implements AccessDeniedHandler{
|
|||||||
@Override
|
@Override
|
||||||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
|
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
|
||||||
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
||||||
response.getWriter().print("{\"code\":401,\"message\":\""+"未认证:"+accessDeniedException.getMessage()+"\"}");
|
response.getWriter().print(JSONUtil.parse(CommonResult.unauthorized(accessDeniedException.getMessage())));
|
||||||
response.getWriter().flush();
|
response.getWriter().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.macro.mall.portal.component;
|
package com.macro.mall.portal.component;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ public class GoAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
|||||||
@Override
|
@Override
|
||||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
|
||||||
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
||||||
response.getWriter().print("{\"code\":403,\"message\":\""+"未授权:"+authException.getMessage()+"\"}");
|
response.getWriter().print(JSONUtil.parse(CommonResult.forbidden(authException.getMessage())));
|
||||||
response.getWriter().flush();
|
response.getWriter().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.macro.mall.portal.component;
|
package com.macro.mall.portal.component;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ public class GoAuthenticationFailureHandler implements AuthenticationFailureHand
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
|
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
|
||||||
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
||||||
response.getWriter().print("{\"code\":500,\"message\":\""+"登录失败:"+exception.getMessage()+"\"}");
|
response.getWriter().print(JSONUtil.parse(CommonResult.failed("登录失败:"+exception.getMessage())));
|
||||||
response.getWriter().flush();
|
response.getWriter().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.macro.mall.portal.component;
|
package com.macro.mall.portal.component;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ public class GoAuthenticationSuccessHandler implements AuthenticationSuccessHand
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
||||||
response.getWriter().print("{\"code\":200,\"message\":\"登录成功\"}");
|
response.getWriter().print(JSONUtil.parse(CommonResult.success(null,"登录成功")));
|
||||||
response.getWriter().flush();
|
response.getWriter().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.macro.mall.portal.component;
|
package com.macro.mall.portal.component;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ public class GoLogoutSuccessHandler implements LogoutSuccessHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
response.setHeader("Content-Type", "application/json;charset=utf-8");
|
||||||
response.getWriter().print("{\"code\":200,\"message\":\"已注销\"}");
|
response.getWriter().print(JSONUtil.parse(CommonResult.success(null,"已注销")));
|
||||||
response.getWriter().flush();
|
response.getWriter().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user