Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#2 inquiry profile #47

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -86,7 +86,6 @@ public void setProfileImage(Image image) {

public void update(ProfileRequestDto requestDto) {
this.name = requestDto.getName();
this.email = requestDto.getEmail();
this.introduction = requestDto.getIntroduction();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/profile")
@RequestMapping("api/profile")
@RequiredArgsConstructor
public class ProfileController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@Getter
public class ProfileRequestDto {
private String name;
private String email;
private String introduction;
private String password;
private String newPassword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ProfileResponseDto editProfile(Long id, ProfileRequestDto requestDto) {
() -> new NotFoundUserException()
);

user.update(requestDto); // 이메일, 이름, 한줄소개 수정
user.update(requestDto); // 이름, 한줄소개 수정

if (requestDto.getPassword() != null && !requestDto.getPassword().isEmpty()) { // 비밀번호가 입력되어 있을때만 비밀번호 검사 시작
if (passwordEncoder.matches(requestDto.getPassword(), user.getPassword())) { // DB에 저장된 비밀번호와 일치하지 않는지 검사
Expand All @@ -67,10 +67,11 @@ public ProfileResponseDto editProfile(Long id, ProfileRequestDto requestDto) {
*/
private void validationPassword(ProfileRequestDto requestDto, String userPassword) {
if (!requestDto.getNewPassword().matches("^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!@#$%^&*])[a-zA-Z\\d!@#$%^&*]{10,}$")) { // 비밀번호를 올바른 형식으로 바꾸려는 검사
if (passwordEncoder.matches(requestDto.getNewPassword(), userPassword)) { // 이전과 같은 비밀번호로 수정하는지 검사
throw new UnacceptablePasswordException();
}
throw new PasswordPatternException();
}

if (passwordEncoder.matches(requestDto.getNewPassword(), userPassword)) { // 이전과 같은 비밀번호로 수정하는지 검사
throw new UnacceptablePasswordException();
}
}
}