From 202b741c9acaf5583064bed87d89b02eda3e272d Mon Sep 17 00:00:00 2001 From: gwon11225 Date: Tue, 27 Aug 2024 08:50:23 +0900 Subject: [PATCH] =?UTF-8?q?Feat=20::=20user=20details=20service=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gradle/8.8/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .idea/gradle.xml | 2 -- .idea/misc.xml | 4 ++- .idea/modules.xml | 10 ------ .../service/UserDetailsServiceImpl.kt | 29 ++++++++++++++++++ 5 files changed, 32 insertions(+), 13 deletions(-) delete mode 100644 .idea/modules.xml create mode 100644 src/main/kotlin/com/byebye/chapterTwo/domain/member/application/service/UserDetailsServiceImpl.kt diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index a5d7a5e05e846ff75ee0cc8d662e37aa7f580224..bd5d00df9861b0bf05a1cf58e845e32a5c440870 100644 GIT binary patch literal 17 VcmZRc9(P8oTI0>=51wH@( literal 17 VcmZRc9(P8oTI0 - \ 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