diff --git a/src/main/java/AIWA/MCPBackend_Member/Controller/MemberController.java b/src/main/java/AIWA/MCPBackend_Member/Controller/MemberController.java index 14f0825..59a02f7 100644 --- a/src/main/java/AIWA/MCPBackend_Member/Controller/MemberController.java +++ b/src/main/java/AIWA/MCPBackend_Member/Controller/MemberController.java @@ -70,10 +70,10 @@ public ListResult getAllMembers() { } @PostMapping("/update-credentials") - public CommonResult updateCredentials(@RequestBody CompanyDto companyDto) { - System.out.println(companyDto.getAccessKey()); - System.out.println(companyDto.getSecretKey()); - memberService.addOrUpdateKeys(companyDto.getUserId(),companyDto.getCompany(),companyDto.getAccessKey(), companyDto.getSecretKey()); + public CommonResult updateCredentials(@RequestBody MemberCredentialDTO memberCredentialDTO) { + System.out.println(memberCredentialDTO.getAccessKey()); + System.out.println(memberCredentialDTO.getSecretKey()); + memberService.addOrUpdateKeys(memberCredentialDTO.getEmail(),memberCredentialDTO.getAccessKey(), memberCredentialDTO.getSecretKey()); return responseService.getSuccessResult(); } diff --git a/src/main/java/AIWA/MCPBackend_Member/Service/member/MemberService.java b/src/main/java/AIWA/MCPBackend_Member/Service/member/MemberService.java index dd23a81..3b7da9e 100644 --- a/src/main/java/AIWA/MCPBackend_Member/Service/member/MemberService.java +++ b/src/main/java/AIWA/MCPBackend_Member/Service/member/MemberService.java @@ -22,7 +22,9 @@ public Member registerMember(MemberRequestDto memberRequestDto) { if (memberRepository.findByEmail(memberRequestDto.getEmail()) != null) { throw new RuntimeException("Email already exists"); } + s3Service.createUserDirectory(memberRequestDto.getEmail()); Member regiMember=new Member(memberRequestDto.getName(), memberRequestDto.getPassword(), memberRequestDto.getEmail()); + return memberRepository.save(regiMember); } @@ -57,13 +59,12 @@ public List getAllMembers() { } - public Member addOrUpdateKeys(String email, String company,String access_key,String secret_key) { + public Member addOrUpdateKeys(String email,String access_key,String secret_key) { Member member = getMemberByEmail(email); member.setAccess_key(access_key); member.setSecret_key(secret_key); - s3Service.createUserDirectory(company); - s3Service.createTfvarsFile(company,access_key,secret_key); + s3Service.createTfvarsFile(email,access_key,secret_key); return memberRepository.save(member); } diff --git a/src/main/java/AIWA/MCPBackend_Member/Service/s3/S3Service.java b/src/main/java/AIWA/MCPBackend_Member/Service/s3/S3Service.java index 9fb3e56..893a29c 100644 --- a/src/main/java/AIWA/MCPBackend_Member/Service/s3/S3Service.java +++ b/src/main/java/AIWA/MCPBackend_Member/Service/s3/S3Service.java @@ -13,8 +13,8 @@ public class S3Service { private final AmazonS3 s3Client; private final String bucketName = "aiwa-terraform"; - public void createUserDirectory(String company) { - String userPrefix = "users/" + company + "/"; + public void createUserDirectory(String userId) { + String userPrefix = "users/" + userId + "/"; // 초기 main.tf 및 terraform.tfstate 파일을 업로드합니다 uploadInitialFiles(userPrefix); } @@ -64,8 +64,8 @@ public void deleteUserDirectory(String userId) { } - public void createTfvarsFile(String company, String accessKey, String secretKey) { - String userPrefix = "users/" + company + "/"; + public void createTfvarsFile(String userId, String accessKey, String secretKey) { + String userPrefix = "users/" + userId + "/"; String tfvarsContent = String.format(""" aws_access_key = "%s" aws_secret_key = "%s"