Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Feat :: user details service 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gwon11225 committed Aug 26, 2024
1 parent 33f5e0d commit 202b741
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
Binary file modified .gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
2 changes: 0 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 202b741

Please sign in to comment.