Skip to content

Commit 6b8b34a

Browse files
committed
feat: 이메일 마스킹 유틸 추가 및 Auth 요청에 적용
1 parent f5feeda commit 6b8b34a

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/main/java/site/praytogether/pray_together/domain/auth/presentation/AuthController.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import site.praytogether.pray_together.domain.auth.presentation.dto.OtpVerifyRequest;
2727
import site.praytogether.pray_together.domain.auth.presentation.dto.ReissuePasswordRequest;
2828
import site.praytogether.pray_together.domain.auth.presentation.dto.SignupRequest;
29+
import site.praytogether.pray_together.domain.base.EmailMaskingUtil;
2930
import site.praytogether.pray_together.domain.base.MessageResponse;
3031

3132
@RestController
@@ -62,9 +63,9 @@ public ResponseEntity<MessageResponse> getEmailOtp(@Valid @RequestBody EmailOtpR
6263

6364
@PostMapping("/otp/email/verification")
6465
public ResponseEntity<MessageResponse> verifyOtp(@Valid @RequestBody OtpVerifyRequest request) {
65-
log.info("[API] OTP 검증 요청 시작 email={} otp={}", request.getEmail(), request.getOtp());
66+
log.info("[API] OTP 검증 요청 시작 email={}", EmailMaskingUtil.mask(request.getEmail()));
6667
boolean otpResult = authApplication.verifyOtp(request);
67-
log.info("[API] OTP 검증 요청 종료 email={} otp={}", request.getEmail(), request.getOtp());
68+
log.info("[API] OTP 검증 요청 종료 email={}", EmailMaskingUtil.mask(request.getEmail()));
6869
if (otpResult == false) {
6970
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
7071
.body(MessageResponse.of("인증 번호가 일치하지 않습니다."));
@@ -101,17 +102,17 @@ public ResponseEntity<MessageResponse> changePassword(
101102

102103
@PostMapping("/google")
103104
public ResponseEntity<GoogleAuthResponse> googleAuth(@Valid @RequestBody GoogleAuthRequest request) {
104-
log.info("[API] Google 인증 요청 시작 email={}", request.getEmail());
105+
log.info("[API] Google 인증 요청 시작 email={}", EmailMaskingUtil.mask(request.getEmail()));
105106
GoogleAuthResponse response = authApplication.googleAuth(request);
106-
log.info("[API] Google 인증 요청 종료 email={} isNewMember={}", request.getEmail(), response.isNewMember());
107+
log.info("[API] Google 인증 요청 종료 email={} isNewMember={}", EmailMaskingUtil.mask(request.getEmail()), response.isNewMember());
107108
return ResponseEntity.status(HttpStatus.OK).body(response);
108109
}
109110

110111
@PostMapping("/google/signup")
111112
public ResponseEntity<LoginResponse> googleSignup(@Valid @RequestBody GoogleSignupRequest request) {
112-
log.info("[API] Google 회원가입 요청 시작 email={}", request.getEmail());
113+
log.info("[API] Google 회원가입 요청 시작 email={}", EmailMaskingUtil.mask(request.getEmail()));
113114
LoginResponse response = authApplication.googleSignup(request);
114-
log.info("[API] Google 회원가입 요청 종료 email={}", request.getEmail());
115+
log.info("[API] Google 회원가입 요청 종료 email={}", EmailMaskingUtil.mask(request.getEmail()));
115116
return ResponseEntity.status(HttpStatus.CREATED).body(response);
116117
}
117118

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package site.praytogether.pray_together.domain.base;
2+
3+
public final class EmailMaskingUtil {
4+
5+
private EmailMaskingUtil() {
6+
}
7+
8+
public static String mask(String email) {
9+
if (email == null || !email.contains("@")) {
10+
return "***";
11+
}
12+
13+
String[] parts = email.split("@");
14+
String local = parts[0];
15+
String domain = parts[1];
16+
17+
if (local.length() <= 2) {
18+
return "**@" + domain;
19+
}
20+
21+
return local.substring(0, 2) + "***@" + domain;
22+
}
23+
}

0 commit comments

Comments
 (0)