Skip to content

Commit

Permalink
FIX :: LogoutHandler Unauthorized -> 500 Error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Daybreak312 committed May 8, 2024
1 parent d34bcc0 commit d2f4dd0
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.info.maeumgagym.security.handler

import com.info.maeumgagym.common.exception.AuthenticationException
import com.info.maeumgagym.core.auth.port.out.RevokeTokensPort
import com.info.maeumgagym.security.authentication.vo.UserModelAuthentication
import org.springframework.security.core.Authentication
import org.springframework.security.web.authentication.logout.LogoutHandler
import org.springframework.stereotype.Component
Expand All @@ -23,8 +25,14 @@ class CustomLogoutHandler(
override fun logout(
request: HttpServletRequest,
response: HttpServletResponse,
authentication: Authentication
authentication: Authentication?
) {
authentication ?: throw AuthenticationException.UNAUTHORIZED

if (authentication !is UserModelAuthentication) {
throw AuthenticationException.UNAUTHORIZED
}

revokeTokensPort.revoke()
}
}

0 comments on commit d2f4dd0

Please sign in to comment.