Skip to content

Commit

Permalink
✨ [feature][#4] BCryptPasswordEncoder 객체 주입 -> 비밀번호, 주민등록번호 or 사업자등록번…
Browse files Browse the repository at this point in the history
…호 암호화

✨ [feature][#4] BCryptPasswordEncoder 객체 주입 -> 비밀번호, 주민등록번호 or 사업자등록번호 암호화
  • Loading branch information
Caramel1004 committed Apr 16, 2024
1 parent 006e918 commit ed5a6c7
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moin.remittance.application.v2.user.impl;

import com.moin.remittance.domain.entity.member.v2.MemberEntityV2;
import com.moin.remittance.exception.DuplicateUserIdException;
import com.moin.remittance.exception.InValidPatternTypeException;
import com.moin.remittance.exception.NotFoundMemberException;
Expand All @@ -8,6 +9,7 @@
import com.moin.remittance.repository.v2.MemberRepositoryV2;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;


Expand All @@ -21,6 +23,7 @@
@RequiredArgsConstructor
public class MemberServiceImplV2 implements MemberServiceV2 {
private final MemberRepositoryV2 memberRepositoryV2;
private final BCryptPasswordEncoder bCryptPasswordEncoder;

@Value("${jwt.token.secret}")
private String key;
Expand Down Expand Up @@ -58,8 +61,15 @@ public void saveUser(MemberDTO member) {
if (isExistingUserId) {
throw new DuplicateUserIdException(BAD_DUPLICATE_USERID_INVALID_USERID);
}
// 4. memberDTO 대로 유저 저장
memberRepositoryV2.saveAndFlush(member.toEntity(member));

// 4. 비밀번호, 주민등록번호 or 사업자등록번호 암호화해서 저장
memberRepositoryV2.saveAndFlush(MemberEntityV2.builder()
.userId(member.getUserId())
.password(bCryptPasswordEncoder.encode(member.getPassword()))
.name(member.getName())
.idType(member.getIdType())
.idValue(bCryptPasswordEncoder.encode(member.getIdValue()))
.build());
}

@Override
Expand Down

0 comments on commit ed5a6c7

Please sign in to comment.