Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c8a5bf2
:sparkles: feat: User ์—”ํ‹ฐํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
ojy0903 Jan 29, 2026
f9926d9
:sparkles: feat: UserSignUpException -> UserException ์œผ๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝ, UserEโ€ฆ
ojy0903 Jan 29, 2026
94345d4
:sparkles: feat: EmailService ๊ธฐ์กด ๊ฐ€์ž…์‹œ ์ด๋ฉ”์ผ ์ธ์ฆ ๋กœ์ง์„ ํ…œํ”Œ๋ฆฟ ๋ฉ”์„œ๋“œํ™” & ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •์„ โ€ฆ
ojy0903 Jan 29, 2026
e5be6f8
:sparkles: feat: UserService ์‹ค์ œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
ojy0903 Jan 29, 2026
4025e6d
:sparkles: feat: UserController ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •์„ ์œ„ํ•œ ์ด๋ฉ”์ผ ์ธ์ฆ ์ „์†ก API, ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • โ€ฆ
ojy0903 Jan 29, 2026
c7897a5
Merge remote-tracking branch 'refs/remotes/origin/develop' into feat/#13
ojy0903 Jan 29, 2026
07e7340
:bug: fix: ์†Œ์…œ๋กœ๊ทธ์ธ PR ๋จธ์ง€ ์ดํ›„ UserSignUpException -> UserException ๋ณ€๊ฒฝ ์ ์šฉ
ojy0903 Jan 29, 2026
7159647
:sparkles: feat: ์†Œ์…œ๋กœ๊ทธ์ธ PR ๋จธ์ง€ ์ดํ›„ User ์—”ํ‹ฐํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
ojy0903 Jan 29, 2026
c8867ad
:bug: fix: EmailService ์ด๋ฉ”์ผ ์ „์†ก ํ…œํ”Œ๋ฆฟ ๋ฉ”์„œ๋“œ ๊ฒ€์ฆ ๋กœ์ง ์ˆ˜์ •
ojy0903 Jan 29, 2026
f4712c4
:sparkles: feat: UserErrorCode ์ฝ”๋“œ ์ •๋ฆฌ ๋ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๊ด€๋ จ ์ฝ”๋“œ ์ถ”๊ฐ€
ojy0903 Jan 29, 2026
3897a16
:sparkles: feat: UserService ๋‚ด๋ถ€ UserSignUpException -> UserException โ€ฆ
ojy0903 Jan 29, 2026
01e2820
:sparkles: feat: UserController ๋‚ด๋ถ€ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๊ด€๋ จ API ๊ฒฝ๋กœ ์ˆ˜์ • + Swagger Doโ€ฆ
ojy0903 Jan 29, 2026
6b60624
:bug: fix: ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •์„ ์œ„ํ•œ ์ด๋ฉ”์ผ ์ „์†ก ๋‚ด๋ถ€ ๊ฒ€์ฆ ๋กœ์ง ์˜ค๋ฅ˜ ์ˆ˜์ •
ojy0903 Jan 30, 2026
0254bfa
:recycle: refactor: UserException -> UserHandler ๋กœ ํด๋ž˜์Šค๋ช… ๋ณ€๊ฒฝ
ojy0903 Jan 31, 2026
5b1df9d
:recycle: refactor: ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • API response ๋ฅผ created -> from ์œผ๋กœ ๋ณ€๊ฒฝ
ojy0903 Jan 31, 2026
9fba55f
:bug: fix: ์ตœ์ดˆ ํšŒ์›๊ฐ€์ž… ์ด๋ฉ”์ผ ๋ฌธ๊ตฌ / ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ์ด๋ฉ”์ผ ๋ฌธ๊ตฌ ๋ถ„๋ฆฌ, ์ด๋ฉ”์ผ ์ธ์ฆ ์‹œ๊ฐ„ 3๋ถ„์œผ๋กœ ๋ณ€๊ฒฝ
ojy0903 Jan 31, 2026
9e460c8
:recycle: refactor: ์ตœ์ดˆ ํšŒ์›๊ฐ€์ž… ์ด๋ฉ”์ผ ๋ฌธ๊ตฌ / ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ์ด๋ฉ”์ผ ๋ฌธ๊ตฌ ๋ถ„๋ฆฌ -> Subject ๋ฌธ๊ตฌ ๊ตฌ๋ถ„
ojy0903 Jan 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.whereyouad.WhereYouAd.domains.user.application.dto.request;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;

public record PwdResetRequest(
@NotBlank(message = "์ด๋ฉ”์ผ์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
@Email(message = "์ด๋ฉ”์ผ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
String email,
@NotBlank(message = "๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
String password
) {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.whereyouad.WhereYouAd.domains.user.domain.constant;

import com.whereyouad.WhereYouAd.domains.user.exception.UserSignUpException;
import com.whereyouad.WhereYouAd.domains.user.exception.handler.UserHandler;
import com.whereyouad.WhereYouAd.domains.user.exception.code.UserErrorCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +22,6 @@ public static Provider fromRegistrationId(String registrationId) {
return Arrays.stream(Provider.values())
.filter(socialType -> socialType.getRegistrationId().equals(registrationId))
.findFirst()
.orElseThrow(() -> new UserSignUpException(UserErrorCode.NOT_PROVIDE_SOCIAL));
.orElseThrow(() -> new UserHandler(UserErrorCode.NOT_PROVIDE_SOCIAL));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.whereyouad.WhereYouAd.domains.user.domain.service;

import com.whereyouad.WhereYouAd.domains.user.application.dto.response.EmailSentResponse;
import com.whereyouad.WhereYouAd.domains.user.exception.UserSignUpException;
import com.whereyouad.WhereYouAd.domains.user.exception.handler.UserHandler;
import com.whereyouad.WhereYouAd.domains.user.exception.code.UserErrorCode;
import com.whereyouad.WhereYouAd.domains.user.persistence.repository.UserRepository;
import com.whereyouad.WhereYouAd.global.utils.RedisUtil;
Expand All @@ -28,12 +28,29 @@ public class EmailService {
@Value("${spring.mail.username}")
private String senderEmail;

//์ธ์ฆ์ฝ”๋“œ ์ด๋ฉ”์ผ ๋ฐœ์†ก ๋กœ์ง
//์ธ์ฆ์ฝ”๋“œ ์ด๋ฉ”์ผ ๋ฐœ์†ก ๋กœ์ง (์ตœ์ดˆ ํšŒ์›๊ฐ€์ž… ์‹œ)
public EmailSentResponse sendEmail(String toEmail) {

if (userRepository.existsByEmail(toEmail)) { //์ด๋ฏธ ํ•ด๋‹น ์ด๋ฉ”์ผ๋กœ ์ƒ์„ฑํ•œ ๊ณ„์ •์ด ์žˆ์œผ๋ฉด
throw new UserSignUpException(UserErrorCode.USER_EMAIL_DUPLICATE); //์ด๋ฉ”์ผ ์ค‘๋ณต ์˜ˆ์™ธ(ํšŒ์›๊ฐ€์ž… ์‹œ ์‚ฌ์šฉํ–ˆ๋˜ ์˜ˆ์™ธ)
throw new UserHandler(UserErrorCode.USER_EMAIL_DUPLICATE); //์ด๋ฉ”์ผ ์ค‘๋ณต ์˜ˆ์™ธ(ํšŒ์›๊ฐ€์ž… ์‹œ ์‚ฌ์šฉํ–ˆ๋˜ ์˜ˆ์™ธ)
}

String type = "ํšŒ์›๊ฐ€์ž…";

return emailSendTemplate(toEmail, type);
}

//๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •์„ ์œ„ํ•œ ์ธ์ฆ์ฝ”๋“œ ์ด๋ฉ”์ผ ๋ฐœ์†ก ๋กœ์ง (์ด๋ฏธ ํšŒ์›๊ฐ€์ž… ๋œ ์ƒํƒœ์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •)
public EmailSentResponse sendEmailForPwd(String toEmail) {
if (userRepository.existsByEmail(toEmail)) { //์ด๋ฏธ ํšŒ์›๊ฐ€์ž… ๋˜์–ด์žˆ๋Š” ๊ฒƒ์ด ํ™•์ธ๋˜๋ฉด
String type = "๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •";
return emailSendTemplate(toEmail, type); //์ •์ƒ์ ์œผ๋กœ ์ด๋ฉ”์ผ ๋ฐœ์†ก
} else { //๋งŒ์•ฝ ํšŒ์›๊ฐ€์ž… ๋˜์–ด์žˆ์ง€ ์•Š๋‹ค๋ฉด
throw new UserHandler(UserErrorCode.USER_NOT_FOUND); //์˜ˆ์™ธ๋ฐœ์ƒ
}
}

//๊ธฐ์กด ์ด๋ฉ”์ผ ๋ฐœ์†ก ๋กœ์ง ํ…œํ”Œ๋ฆฟ ํ™”
private EmailSentResponse emailSendTemplate(String toEmail, String type) {

//์ธ์ฆ์ฝ”๋“œ ์žฌ์ „์†ก ๋กœ์ง -> ์ด๋ฏธ Redis ์— ํ•ด๋‹น ์ด๋ฉ”์ผ ์ธ์ฆ์ฝ”๋“œ๊ฐ€ ์žˆ์„์‹œ ์‚ญ์ œ
String redisKey = "CODE:" + toEmail;
Expand All @@ -58,23 +75,24 @@ public EmailSentResponse sendEmail(String toEmail) {
//์‹ค์ œ ์ธ์ฆ ์ฝ”๋“œ๊ฐ€ ๋‹ด๊ธด ์ด๋ฉ”์ผ ์ „์†ก
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(toEmail);
message.setSubject("whereyouad ํšŒ์›๊ฐ€์ž… ์ธ์ฆ๋ฒˆํ˜ธ");
message.setText("์ธ์ฆ๋ฒˆํ˜ธ: " + authCode);
//์–ด๋–ค ์œ ํ˜•์˜ ์ธ์ฆ(์ตœ์ดˆ ํšŒ์›๊ฐ€์ž… or ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •) ์ธ์ง€ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ธ์ฆ์ฝ”๋“œ ๋ฐœ์†ก
message.setSubject("whereyouad " + type + " ์ธ์ฆ๋ฒˆํ˜ธ");
message.setText("[Where You Ad] " + type + "\n ์ธ์ฆ ๋ฒˆํ˜ธ๋Š” [" + authCode + "] ์ž…๋‹ˆ๋‹ค.");
message.setFrom(senderEmail);

emailSender.send(message); //๋งŒ์•ฝ ์‹ค์ œ ์กด์žฌํ•˜๋Š” ์ด๋ฉ”์ผ์ธ๋ฐ ์‚ฌ์šฉ์ž๊ฐ€ ์˜คํƒ€๋ฅผ ๋ƒˆ๋‹ค๋ฉด
} catch (MailException e) { //์˜ˆ์™ธ ๋ฐœ์ƒ
throw new UserSignUpException(UserErrorCode.USER_EMAIL_NOT_VALID); //ํ†ตํ•ฉ ์‘๋‹ต ์ฒ˜๋ฆฌ ์˜ˆ์™ธ๋กœ ๋ฐ˜ํ™˜
throw new UserHandler(UserErrorCode.USER_EMAIL_NOT_VALID); //ํ†ตํ•ฉ ์‘๋‹ต ์ฒ˜๋ฆฌ ์˜ˆ์™ธ๋กœ ๋ฐ˜ํ™˜
}

}

//Redis์— ์ €์žฅ (Key: "CODE:์ด๋ฉ”์ผ", Value: "123456", ์œ ํšจ์‹œ๊ฐ„: 300์ดˆ(5๋ถ„))
//Redis์— ์ €์žฅ (Key: "CODE:์ด๋ฉ”์ผ", Value: "123456", ์œ ํšจ์‹œ๊ฐ„: 180์ดˆ(3๋ถ„))
//ํ…Œ์ŠคํŠธ ๊ณ„์ •๋„ ์ธ์ฆ์€ ํ•ด์•ผํ•˜๋‹ˆ Redis ์— ์ฝ”๋“œ๊ฐ€ ์ €์žฅ ๋˜์–ด์•ผ ํ•จ.
//ํ…Œ์ŠคํŠธ ๊ณ„์ •์˜ ์ธ์ฆ์€ ์„œ๋ฒ„ ๋กœ๊ทธ๋ฅผ ํ†ตํ•ด ์ธ์ฆ์ฝ”๋“œ๋ฅผ ์–ป์–ด ์ž…๋ ฅ.
redisUtil.setDataExpire("CODE:" + toEmail, authCode, 60 * 5L);
redisUtil.setDataExpire("CODE:" + toEmail, authCode, 60 * 3L);

return new EmailSentResponse("์ธ์ฆ์ฝ”๋“œ๋ฅผ ์ด๋ฉ”์ผ๋กœ ์ „์†กํ–ˆ์Šต๋‹ˆ๋‹ค.", toEmail, 300L);
return new EmailSentResponse("์ธ์ฆ์ฝ”๋“œ๋ฅผ ์ด๋ฉ”์ผ๋กœ ์ „์†กํ–ˆ์Šต๋‹ˆ๋‹ค.", toEmail, 180L);
}

//์ธ์ฆ์ฝ”๋“œ ๊ฒ€์ฆ ๋ฉ”์„œ๋“œ
Expand All @@ -85,7 +103,7 @@ public void verifyEmailCode(String email, String inputCode) {

//๋งŒ์•ฝ ์ธ์ฆ์ฝ”๋“œ๊ฐ€ ์—†๊ฑฐ๋‚˜ ์ž˜๋ชป ์ž…๋ ฅํ–ˆ๋‹ค๋ฉด,
if (savedCode == null || !savedCode.equals(inputCode)) {
throw new UserSignUpException(UserErrorCode.USER_EMAIL_AUTH_INVALID); //์˜ˆ์™ธ ๋ฐœ์ƒ(BAD_REQUEST)
throw new UserHandler(UserErrorCode.USER_EMAIL_AUTH_INVALID); //์˜ˆ์™ธ ๋ฐœ์ƒ(BAD_REQUEST)
}

//์ •์ƒ์ ์œผ๋กœ ์ธ์ฆ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ–ˆ๋‹ค๋ฉด,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.whereyouad.WhereYouAd.domains.user.domain.service;

import com.whereyouad.WhereYouAd.domains.user.exception.UserSignUpException;
import com.whereyouad.WhereYouAd.domains.user.exception.handler.UserHandler;
import com.whereyouad.WhereYouAd.domains.user.exception.code.UserErrorCode;
import com.whereyouad.WhereYouAd.domains.user.domain.constant.UserStatus;
import com.whereyouad.WhereYouAd.domains.user.application.mapper.UserConverter;
Expand All @@ -26,7 +26,7 @@ public class UserService {
//ํšŒ์›๊ฐ€์ž… ๋ฉ”์„œ๋“œ
public SignUpResponse signUpUser(SignUpRequest request) {
if (userRepository.existsByEmail(request.email())) { //์ด๋ฏธ ์ด๋ฉ”์ผ๋กœ ๋งŒ๋“  ๊ณ„์ •์ด ์กด์žฌํ•  ์‹œ
throw new UserSignUpException(UserErrorCode.USER_EMAIL_DUPLICATE); //์ด๋ฉ”์ผ ์ค‘๋ณต ์˜ˆ์™ธ
throw new UserHandler(UserErrorCode.USER_EMAIL_DUPLICATE); //์ด๋ฉ”์ผ ์ค‘๋ณต ์˜ˆ์™ธ
}

//์ถ”๊ฐ€ : ์ด๋ฉ”์ผ ์ธ์ฆ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ -> ์•…์˜์  ๊ณต๊ฒฉ์ž๊ฐ€ ์ด๋ฉ”์ผ ์ธ์ฆ์„ ๊ฑด๋„ˆ๋›ฐ๊ณ  ํšŒ์›๊ฐ€์ž… URL ๋“ฑ์œผ๋กœ ๋ฐ”๋กœ ๋“ค์–ด์™”์„ ๊ฒฝ์šฐ
Expand All @@ -35,7 +35,7 @@ public SignUpResponse signUpUser(SignUpRequest request) {

//์ธ์ฆ์ด ์•ˆ๋˜์—ˆ๋‹ค๋ฉด,
if (isEmailVerified == null || !isEmailVerified.equals("TRUE")) {
throw new UserSignUpException(UserErrorCode.USER_EMAIL_NOT_VERIFIED); //์˜ˆ์™ธ ๋ฐœ์ƒ(UNAUTHORIZED)
throw new UserHandler(UserErrorCode.USER_EMAIL_NOT_VERIFIED); //์˜ˆ์™ธ ๋ฐœ์ƒ(UNAUTHORIZED)
}

//๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” -> SecurityConfig ํด๋ž˜์Šค ๋‚ด ์—์„œ BCryptPasswordEncoder ๋ฅผ Bean ๋“ฑ๋กํ•œ๊ฑฐ๋กœ ์‚ฌ์šฉ
Expand All @@ -57,4 +57,32 @@ public SignUpResponse signUpUser(SignUpRequest request) {
//Response DTO ๋กœ ๋ณ€ํ™˜ ๋ฐ ๋ฐ˜ํ™˜
return UserConverter.toSignInResponse(savedUser);
}

//์ด๋ฏธ ํšŒ์›๊ฐ€์ž… ๋œ ํšŒ์›์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๋ฉ”์„œ๋“œ
public void passwordReset(String email, String password) {
//์ด๋ฉ”์ผ ์ธ์ฆ์ด ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธ
String isEmailVerified = redisUtil.getData("VERIFIED:" + email);

//์ธ์ฆ์ด ์•ˆ๋˜์—ˆ๋‹ค๋ฉด,
if (isEmailVerified == null || !isEmailVerified.equals("TRUE")) {
throw new UserHandler(UserErrorCode.USER_EMAIL_NOT_VERIFIED); //์˜ˆ์™ธ ๋ฐœ์ƒ
}

//๊ธฐ์กด ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•  ์‹œ ์˜ˆ์™ธ ๋ฐœ์ƒ
User user = userRepository.findUserByEmail(email)
.orElseThrow(() -> new UserHandler(UserErrorCode.USER_NOT_FOUND));

String oldPassword = user.getPassword();

if (passwordEncoder.matches(password, oldPassword)) { //์ƒˆ๋กœ์šด ๋น„๋ฐ€๋ฒˆํ˜ธ == ์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ์ด๋ฉด
throw new UserHandler(UserErrorCode.USER_PASSWORD_SAME_AS_OLD); //์˜ˆ์™ธ ๋ฐœ์ƒ
}

//์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” & ์ €์žฅ
String newPassword = passwordEncoder.encode(password);
//๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ (JPA Dirty Checking)
user.resetPassword(newPassword);

redisUtil.deleteData("VERIFIED:" + email);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum UserErrorCode implements BaseErrorCode {
USER_EMAIL_NOT_VALID(HttpStatus.BAD_REQUEST, "USER_400_2", "ํ•ด๋‹น ์ด๋ฉ”์ผ๋กœ ๋ฉ”์ผ ์ „์†ก์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."),
USER_EMAIL_AUTH_INVALID(HttpStatus.BAD_REQUEST, "USER_400_3", "์ธ์ฆ ์ฝ”๋“œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),
NOT_PROVIDE_SOCIAL(HttpStatus.BAD_REQUEST, "USER_400_4", "์ง€์›ํ•˜์ง€ ์•Š๋Š” ์†Œ์…œ ๋กœ๊ทธ์ธ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค."),
USER_PASSWORD_SAME_AS_OLD(HttpStatus.BAD_REQUEST, "USER_400_5", "์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๋™์ผํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."),

// 401
USER_EMAIL_NOT_VERIFIED(HttpStatus.UNAUTHORIZED, "USER_401_1", "์ด๋ฉ”์ผ ์ธ์ฆ์ด ์ง„ํ–‰๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.whereyouad.WhereYouAd.domains.user.exception.handler;

import com.whereyouad.WhereYouAd.global.exception.AppException;
import com.whereyouad.WhereYouAd.global.exception.BaseErrorCode;

public class UserHandler extends AppException {
public UserHandler(BaseErrorCode errorCode) {
super(errorCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public class User extends BaseEntity {
public void updateProfile(String name){
this.name = name;
}


public void resetPassword(String password) {
this.password = password;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.whereyouad.WhereYouAd.domains.user.presentation;

import com.whereyouad.WhereYouAd.domains.user.application.dto.request.EmailRequest;
import com.whereyouad.WhereYouAd.domains.user.application.dto.request.PwdResetRequest;
import com.whereyouad.WhereYouAd.domains.user.application.dto.response.EmailSentResponse;
import com.whereyouad.WhereYouAd.domains.user.domain.service.EmailService;
import com.whereyouad.WhereYouAd.domains.user.domain.service.UserService;
Expand Down Expand Up @@ -48,4 +49,22 @@ public ResponseEntity<DataResponse<String>> verifyEmail(@RequestBody @Valid Emai
DataResponse.from("์ด๋ฉ”์ผ ์ธ์ฆ์ด ์„ฑ๊ณต์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
);
}

@PostMapping("/password-reset/request")
public ResponseEntity<DataResponse<EmailSentResponse>> sendEmailForPwdReset(@RequestBody @Valid EmailRequest.Send request) {
EmailSentResponse emailSentResponse = emailService.sendEmailForPwd(request.email());

return ResponseEntity.ok(
DataResponse.from(emailSentResponse)
);
}

@PostMapping("/password-reset/confirm")
public ResponseEntity<DataResponse<String>> resetPassword(@RequestBody @Valid PwdResetRequest request) {
userService.passwordReset(request.email(), request.password());

return ResponseEntity.ok(
DataResponse.from("๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.whereyouad.WhereYouAd.domains.user.presentation.docs;

import com.whereyouad.WhereYouAd.domains.user.application.dto.request.EmailRequest;
import com.whereyouad.WhereYouAd.domains.user.application.dto.request.PwdResetRequest;
import com.whereyouad.WhereYouAd.domains.user.application.dto.request.SignUpRequest;
import com.whereyouad.WhereYouAd.domains.user.application.dto.response.EmailSentResponse;
import com.whereyouad.WhereYouAd.domains.user.application.dto.response.SignUpResponse;
Expand All @@ -19,7 +20,7 @@ public interface UserControllerDocs {
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "400_2", description = "์ด๋ฉ”์ผ ์ค‘๋ณต ํšŒ์› ์กด์žฌ")
@ApiResponse(responseCode = "400_1", description = "์ด๋ฉ”์ผ ์ค‘๋ณต ํšŒ์› ์กด์žฌ")
})
public ResponseEntity<DataResponse<SignUpResponse>> signUp(@RequestBody @Valid SignUpRequest request);

Expand All @@ -30,7 +31,7 @@ public interface UserControllerDocs {
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "400_3", description = "์ด๋ฉ”์ผ ์ „์†ก์‹คํŒจ(์ด๋ฉ”์ผ ์˜คํƒ€ ๋“ฑ)")
@ApiResponse(responseCode = "400_2", description = "์ด๋ฉ”์ผ ์ „์†ก์‹คํŒจ(์ด๋ฉ”์ผ ์˜คํƒ€ ๋“ฑ)")
})
public ResponseEntity<DataResponse<EmailSentResponse>> sendEmail(@RequestBody @Valid EmailRequest.Send request);

Expand All @@ -40,7 +41,30 @@ public interface UserControllerDocs {
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "400_4", description = "์‹คํŒจ(์ธ์ฆ์ฝ”๋“œ ๋ถˆ์ผ์น˜)")
@ApiResponse(responseCode = "400_3", description = "์‹คํŒจ(์ธ์ฆ์ฝ”๋“œ ๋ถˆ์ผ์น˜)")
})
public ResponseEntity<DataResponse<String>> verifyEmail(@RequestBody @Valid EmailRequest.Verify request);

@Operation(
summary = "์‚ฌ์šฉ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •์„ ์œ„ํ•œ ์ด๋ฉ”์ผ ์ธ์ฆ์ฝ”๋“œ ์ „์†ก API",
description = "ํšŒ์›์˜ ์ด๋ฉ”์ผ์„ ์ž…๋ ฅ๋ฐ›์•„ ํ•ด๋‹น ์ด๋ฉ”์ผ๋กœ ์ธ์ฆ์ฝ”๋“œ๋ฅผ ์ „์†กํ•ฉ๋‹ˆ๋‹ค(์ธ์ฆ์ฝ”๋“œ ๊ฒ€์ฆ์€ ๊ธฐ์กด /email-verify ๋กœ ์ง„ํ–‰)"
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "400_2", description = "์ด๋ฉ”์ผ ์ „์†ก์‹คํŒจ(์ด๋ฉ”์ผ ์˜คํƒ€ ๋“ฑ)"),
@ApiResponse(responseCode = "404_1", description = "ํ•ด๋‹น ์ด๋ฉ”์ผ๋กœ ๊ฐ€์ž…ํ•œ ํšŒ์› ์กด์žฌํ•˜์ง€ ์•Š์Œ")
})
public ResponseEntity<DataResponse<EmailSentResponse>> sendEmailForPwdReset(@RequestBody @Valid EmailRequest.Send request);

@Operation(
summary = "์‚ฌ์šฉ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • API",
description = "ํšŒ์›์˜ ์ด๋ฉ”์ผ๊ณผ ์žฌ์„ค์ •ํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žฌ์„ค์ •(์ด์ „๊ณผ ๊ฐ™์€ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ผ ๊ฒฝ์šฐ ์˜ˆ์™ธ ๋ฐœ์ƒ)"
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "400_5", description = "์ด์ „ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๋™์ผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋ณ€๊ฒฝ ๋ถˆ๊ฐ€"),
@ApiResponse(responseCode = "401_1", description = "์ด๋ฉ”์ผ ์ธ์ฆ ์ง„ํ–‰๋˜์ง€ ์•Š์Œ"),
@ApiResponse(responseCode = "404_1", description = "ํ•ด๋‹น ์ด๋ฉ”์ผ๋กœ ๊ฐ€์ž…ํ•œ ํšŒ์› ์กด์žฌํ•˜์ง€ ์•Š์Œ")
})
public ResponseEntity<DataResponse<String>> resetPassword(@RequestBody @Valid PwdResetRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.whereyouad.WhereYouAd.global.security.oauth2.service;

import com.whereyouad.WhereYouAd.domains.user.exception.handler.UserHandler;
import com.whereyouad.WhereYouAd.global.security.oauth2.dto.*;
import com.whereyouad.WhereYouAd.domains.user.domain.constant.Provider;
import com.whereyouad.WhereYouAd.domains.user.exception.UserSignUpException;
import com.whereyouad.WhereYouAd.domains.user.exception.code.UserErrorCode;
import com.whereyouad.WhereYouAd.domains.user.persistence.entity.AuthProviderAccount;
import com.whereyouad.WhereYouAd.domains.user.persistence.entity.User;
Expand Down Expand Up @@ -50,7 +50,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic
} else if (provider == Provider.KAKAO){
oAuth2Response = new KaKaoResponse(oAuth2User.getAttributes());
} else {
throw new UserSignUpException(UserErrorCode.NOT_PROVIDE_SOCIAL);
throw new UserHandler(UserErrorCode.NOT_PROVIDE_SOCIAL);
}

// ์‚ฌ์šฉ์ž ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ณ ์œ  id (์ œ๊ณต์ž + ์†Œ์…œ ๋ฐœ๊ธ‰ id) -> (์ค‘๋ณต ํšŒ์› ๊ฐ€์ž… ๋ฐฉ์ง€)
Expand All @@ -69,7 +69,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic
user = userOptional.get();
// ๊ธฐ์กด ์ด๋ฉ”์ผ์— ํ•ด๋‹นํ•˜๋Š” ์œ ์ €๊ฐ€ ์กด์žฌํ•˜์ง€๋งŒ ์ด๋ฉ”์ผ ์ธ์ฆ์ด ์•ˆ๋œ ๊ฒฝ์šฐ -> ์—ฐ๋™ ๋ถˆ๊ฐ€
if (!user.isEmailVerified()) {
throw new UserSignUpException(UserErrorCode.USER_EMAIL_NOT_VERIFIED);
throw new UserHandler(UserErrorCode.USER_EMAIL_NOT_VERIFIED);
}
}
// ์‹ ๊ทœ ์œ ์ €(๊ธฐ์กด email X, ์†Œ์…œ ๋กœ๊ทธ์ธ ์ฒ˜์Œ) -> DB์— ์ €์žฅ
Expand Down