Compare commits
5 Commits
feature/re
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c96502652 | ||
|
|
a68257b9c6 | ||
|
|
fcfdefbb00 | ||
|
|
cd24dfb6b1 | ||
|
|
d80828026c |
@@ -43,14 +43,14 @@ public class UserController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public ResponseEntity<SignUpResponse> register(@RequestBody @Valid SignUpRequest request) {
|
public ResponseEntity<SignUpResponse> register(@RequestBody @Valid SignUpRequest request) {
|
||||||
User user = userService.register(request.toSignUpDto(passwordEncoder));
|
User user = userService.register(request.toSignUpDto(passwordEncoder));
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(SignUpResponse.from(user));
|
return ResponseEntity.status(HttpStatus.CREATED).body(SignUpResponse.of(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@Secured("ROLE_GUEST")
|
@Secured("ROLE_GUEST")
|
||||||
public ResponseEntity<UserDeleteResponse> deleteUser(@RequestBody @Valid UserDeleteRequest request) {
|
public ResponseEntity<UserDeleteResponse> deleteUser(@RequestBody @Valid UserDeleteRequest request) {
|
||||||
User user = userService.delete(request.toDeleteUserDto(passwordEncoder));
|
User user = userService.delete(request.toDeleteUserDto(passwordEncoder));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(UserDeleteResponse.from(user));
|
return ResponseEntity.status(HttpStatus.OK).body(UserDeleteResponse.of(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/password")
|
@PutMapping("/password")
|
||||||
@@ -62,7 +62,7 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
User user = userService.changePassword(request.toChangePasswordDto(passwordEncoder));
|
User user = userService.changePassword(request.toChangePasswordDto(passwordEncoder));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(UserChangePasswordResponse.from(user));
|
return ResponseEntity.status(HttpStatus.OK).body(UserChangePasswordResponse.of(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class SignUpResponse {
|
|||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
public static SignUpResponse from(User user) {
|
public static SignUpResponse of(User user) {
|
||||||
return new SignUpResponse(user.getName(), user.getEmail());
|
return new SignUpResponse(user.getName(), user.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class UserChangePasswordResponse {
|
|||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
public static UserChangePasswordResponse from(User user) {
|
public static UserChangePasswordResponse of(User user) {
|
||||||
return new UserChangePasswordResponse(user.getName(), user.getEmail());
|
return new UserChangePasswordResponse(user.getName(), user.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class UserDeleteResponse {
|
|||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
public static UserDeleteResponse from(User user) {
|
public static UserDeleteResponse of(User user) {
|
||||||
return new UserDeleteResponse(user.getName(), user.getEmail());
|
return new UserDeleteResponse(user.getName(), user.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
|
|
||||||
public class ChangePasswordDTO implements PasswordMatches {
|
public class ChangePasswordDTO implements PasswordMatches {
|
||||||
|
|
||||||
|
public ChangePasswordDTO(String email, String oldPassword, String newPassword, PasswordEncoder passwordEncoder) {
|
||||||
|
this.email = email;
|
||||||
|
this.oldPassword = oldPassword;
|
||||||
|
this.newPassword = newPassword;
|
||||||
|
this.passwordEncoder = passwordEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
@NotEmpty(message = "{validation.not.empty.email}")
|
@NotEmpty(message = "{validation.not.empty.email}")
|
||||||
@Email(message = "{validation.email}")
|
@Email(message = "{validation.email}")
|
||||||
private String email;
|
private String email;
|
||||||
@@ -18,13 +25,6 @@ public class ChangePasswordDTO implements PasswordMatches {
|
|||||||
|
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public ChangePasswordDTO(String email, String oldPassword, String newPassword, PasswordEncoder passwordEncoder) {
|
|
||||||
this.email = email;
|
|
||||||
this.oldPassword = oldPassword;
|
|
||||||
this.newPassword = newPassword;
|
|
||||||
this.passwordEncoder = passwordEncoder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
|
|
||||||
public class DeleteUserDTO implements PasswordMatches {
|
public class DeleteUserDTO implements PasswordMatches {
|
||||||
|
|
||||||
|
public DeleteUserDTO(String email, String inputPassword, PasswordEncoder passwordEncoder) {
|
||||||
|
this.email = email;
|
||||||
|
this.inputPassword = inputPassword;
|
||||||
|
this.passwordEncoder = passwordEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
@NotEmpty(message = "{validation.not.empty.email}")
|
@NotEmpty(message = "{validation.not.empty.email}")
|
||||||
@Email(message = "{validation.email}")
|
@Email(message = "{validation.email}")
|
||||||
private String email;
|
private String email;
|
||||||
@@ -15,12 +21,6 @@ public class DeleteUserDTO implements PasswordMatches {
|
|||||||
|
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public DeleteUserDTO(String email, String inputPassword, PasswordEncoder passwordEncoder) {
|
|
||||||
this.email = email;
|
|
||||||
this.inputPassword = inputPassword;
|
|
||||||
this.passwordEncoder = passwordEncoder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean passwordMatches(String password) {
|
public boolean passwordMatches(String password) {
|
||||||
return passwordEncoder.matches(this.inputPassword, password);
|
return passwordEncoder.matches(this.inputPassword, password);
|
||||||
|
|||||||
Reference in New Issue
Block a user