Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gurdl0525 committed Nov 15, 2023
2 parents d3d22e8 + 33930a4 commit 3065410
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ class AuthController(
.setIssuedAt(Date())
.setExpiration(Date(Date().time.plus(2592000000)))
.compact()

@DeleteMapping
fun signOut() {
authService.signOut()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository

@Repository
interface RefreshTokenRepository: CrudRepository<RefreshToken, String> {
interface RefreshTokenRepository : CrudRepository<RefreshToken, String> {

fun findBySub(sub: String): RefreshToken?

fun deleteBySub(sub: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import com.example.onui.domain.auth.presentation.dto.response.TokenResponse
interface AuthService {

fun reissue(refreshToken: String): TokenResponse

fun signOut()
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
package com.example.onui.domain.auth.service

import com.example.onui.domain.auth.repository.RefreshTokenRepository
import com.example.onui.domain.user.repository.UserRepository
import com.example.onui.global.common.facade.UserFacade
import com.example.onui.global.config.jwt.TokenProvider
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class AuthServiceImpl(
private val tokenProvider: TokenProvider
): AuthService {
@Transactional(readOnly = true)
abstract class AuthServiceImpl(
private val tokenProvider: TokenProvider,
private val userFacade: UserFacade,
private val userRepository: UserRepository,
private val refreshTokenRepository: RefreshTokenRepository
) : AuthService {

override fun reissue(refreshToken: String) = tokenProvider.reissue(refreshToken)

@Transactional
override fun signOut() {

val user = userFacade.getCurrentUser()

refreshTokenRepository.deleteBySub(user.sub)
userRepository.delete(user)
}
}

0 comments on commit 3065410

Please sign in to comment.