Skip to content

Commit

Permalink
Refactor: 회원 수정 삭제 최종본 #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Irisation23 committed Aug 30, 2022
1 parent ee1c337 commit c841319
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/nhnacademy/marketgg/auth/entity/Auth.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ private boolean checkProvider(String provider) {
public String updateAuth(final MemberUpdateRequest memberUpdateRequest, PasswordEncoder passwordEncoder) {
String updatedUuid = UUID.randomUUID().toString();
this.uuid = updatedUuid;
this.password = memberUpdateRequest.getPassword();
this.name = memberUpdateRequest.getName();
this.phoneNumber = memberUpdateRequest.getPhoneNumber();
this.passwordUpdatedAt = getUpdateDate(memberUpdateRequest.getPassword(), passwordEncoder);
this.password = passwordEncoder.encode(memberUpdateRequest.getPassword());

return updatedUuid;
}

public void deleteAuth(final AuthWithDrawRequest withdrawAt, PasswordEncoder passwordEncoder) {
if (this.email.equals(withdrawAt.getEmail())
&& passwordEncoder.matches(this.password, withdrawAt.getPassword())) {
&& passwordEncoder.matches(withdrawAt.getPassword(), this.password)) {

this.deletedAt = withdrawAt.getWithdrawAt();
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ private LocalDate getUpdateDate(final String updatedPassword, PasswordEncoder pa
* @return boolean - Null 이 아니고, 기존 비밀번호랑 같으면 false 를 반환.
*/
private boolean isUpdatePassword(final String updatedPassword, PasswordEncoder passwordEncoder) {
return Objects.isNull(updatedPassword) || passwordEncoder.matches(this.password, updatedPassword);
return Objects.isNull(updatedPassword) || passwordEncoder.matches(updatedPassword, this.password);
}

public void updateUuid(final String uuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public UuidTokenResponse update(final String token, final MemberUpdateRequest me
String uuid = tokenUtils.getUuidFromToken(token);
Auth updatedAuth = authRepository.findByUuid(uuid)
.orElseThrow(AuthNotFoundException::new);
memberUpdateRequest.encodingPassword(passwordEncoder);

String updatedUuid = updatedAuth.updateAuth(memberUpdateRequest, passwordEncoder);

redisTemplate.opsForHash()
.delete(uuid, TokenUtils.REFRESH_TOKEN);
List<SimpleGrantedAuthority> roles = roleRepository.findRolesByAuthId(updatedAuth.getId())
Expand All @@ -111,9 +111,6 @@ public void withdraw(final String token, final AuthWithDrawRequest withdrawAuth)

Auth deletedAuth = authRepository.findByUuid(uuid)
.orElseThrow(AuthNotFoundException::new);

withdrawAuth.encodingPassword(passwordEncoder);

deletedAuth.deleteAuth(withdrawAuth, passwordEncoder);
}

Expand Down

0 comments on commit c841319

Please sign in to comment.