Skip to content

Commit 39411c5

Browse files
committed
refactor : (#31) add oauth failerHandler
1 parent 9979ffe commit 39411c5

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package entry.dsm.gitauth.equusgithubauth.global.oauth.handler
2+
3+
import jakarta.servlet.http.HttpServletRequest
4+
import jakarta.servlet.http.HttpServletResponse
5+
import org.springframework.security.core.AuthenticationException
6+
import org.springframework.security.web.authentication.AuthenticationFailureHandler
7+
8+
class CustomOAuth2AuthenticationFailureHandler : AuthenticationFailureHandler {
9+
override fun onAuthenticationFailure(
10+
request: HttpServletRequest,
11+
response: HttpServletResponse,
12+
exception: AuthenticationException
13+
) {
14+
response.contentType = "application/json"
15+
response.status = HttpServletResponse.SC_UNAUTHORIZED
16+
response.writer.write(
17+
"""{error: OAuth2 로그인 실패, message: ${exception.message}}"""
18+
)
19+
}
20+
}

src/main/kotlin/entry/dsm/gitauth/equusgithubauth/global/oauth/handler/GithubAuthenticationFailureHandler.kt

-16
This file was deleted.

0 commit comments

Comments
 (0)