Skip to content

Commit

Permalink
[chore] 비밀번호 api revert
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunwooYi committed Aug 29, 2024
1 parent cec7ecf commit efd7e58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public BaseResponse<?> publicAccount(@AuthenticationPrincipal Users user) {

@Operation(summary = "비밀번호 재설정")
@PatchMapping("account/pw")
public BaseResponse<?> resetPassword(@RequestBody UsersRequestDTO.UpdateUserPassword2DTO updateUserPassword2DTO, @AuthenticationPrincipal Users user) {
public BaseResponse<?> resetPassword(@RequestBody UsersRequestDTO.UpdateUserPasswordDTO updateUserPasswordDTO, @AuthenticationPrincipal Users user) {
Long userId = user.getUserId();
usersService.resetPassword(updateUserPassword2DTO, userId);
usersService.resetPassword2(updateUserPasswordDTO, userId);
return BaseResponse.onSuccess("비밀번호 재설정 완료");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public List<Map<String, String>> searchUserByName(String name) {
public Long findId(String email) {
Long userId = usersRepository.findIdByEmail(email);
return userId;
}

@Transactional
@Override
Expand Down Expand Up @@ -276,17 +277,12 @@ public void deleteProfileImage(String studentId) {
usersRepository.save(user);
}

@Override
public void resetPassword(UsersRequestDTO.UpdateUserPassword2DTO updateUserPassword2DTO, Long userId) {

public void resetPassword2 (UsersRequestDTO.UpdateUserPasswordDTO updateUserPasswordDTO, Long userId) {
Users user = usersRepository.findById(userId)
.orElseThrow(() -> new UsersHandler(ErrorStatus._NOT_FOUND_USER));
if (updateUserPassword2DTO.getPassword1().equals(updateUserPassword2DTO.getPassword2())) {
user.setPassword(passwordEncoder.encode(updateUserPassword2DTO.getPassword1()));
user.setPassword(passwordEncoder.encode(updateUserPasswordDTO.getPassword()));
usersRepository.save(user);
} else {
throw new UsersHandler(ErrorStatus._INVALID_PW);
}

}

private String extractKeyFromUrl(String url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ public interface UsersService {

void deleteProfileImage(String studentId);

void resetPassword(UsersRequestDTO.UpdateUserPassword2DTO updateUserPassword2DTO, Long userId);
void resetPassword2(UsersRequestDTO.UpdateUserPasswordDTO updateUserPasswordDTO, Long userId);
}

0 comments on commit efd7e58

Please sign in to comment.