1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Added unauthorized access response. Added logout.

This commit is contained in:
2023-05-05 02:31:35 +08:00
parent ac39f886b6
commit 3c8adffe42
7 changed files with 78 additions and 6 deletions

View File

@@ -0,0 +1,20 @@
package com.cfive.pinnacle.handler;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.utils.WebUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Component
public class AuthenticationEntryPointHandler implements AuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
String objectResponse = WebUtil.objectResponse(ResponseCode.UNAUTHORIZED, "Unauthorized access", null);
WebUtil.renderString(response, objectResponse);
}
}