diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index a5d7a5e..bd5d00d 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.idea/gradle.xml b/.idea/gradle.xml index a747e8e..f9163b4 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,11 +1,9 @@ - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 8ac3d48..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/main/kotlin/com/byebye/chapterTwo/domain/member/application/service/UserDetailsServiceImpl.kt b/src/main/kotlin/com/byebye/chapterTwo/domain/member/application/service/UserDetailsServiceImpl.kt new file mode 100644 index 0000000..8a5f91c --- /dev/null +++ b/src/main/kotlin/com/byebye/chapterTwo/domain/member/application/service/UserDetailsServiceImpl.kt @@ -0,0 +1,29 @@ +package com.byebye.chapterTwo.domain.member.application.service + +import com.byebye.chapterTwo.domain.member.adapter.out.mapper.MemberMapper +import com.byebye.chapterTwo.domain.member.adapter.out.repository.MemberRepository +import com.byebye.chapterTwo.domain.member.application.exception.MemberErrorCode +import com.byebye.chapterTwo.global.auth.exception.CustomException +import com.byebye.chapterTwo.global.auth.jwt.JwtUserDetails +import org.springframework.data.repository.findByIdOrNull +import org.springframework.security.core.userdetails.UserDetails +import org.springframework.security.core.userdetails.UserDetailsService +import org.springframework.stereotype.Service + +@Service +class UserDetailsServiceImpl( + private val memberRepository : MemberRepository, + private val memberMapper: MemberMapper +): UserDetailsService { + override fun loadUserByUsername(username: String?): UserDetails { + username?: throw CustomException(MemberErrorCode.MEMBER_NOT_FOUND) + + val memberEntity = memberRepository + .findByName(username) + ?: throw CustomException(MemberErrorCode.MEMBER_NOT_FOUND) + + val member = memberMapper.toDomain(memberEntity) + + return JwtUserDetails(member) + } +} \ No newline at end of file