Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package app.module.front.config.application.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiResponse<T> {
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@@ -18,6 +18,9 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@@ -31,16 +34,16 @@ class GetUserPasswordController {
|
||||
private final GetHouseholdPortIn getHouseholdPortIn;
|
||||
|
||||
@PostMapping(path = "/api/front/info/user/password/auth")
|
||||
ResponseEntity<?> operate(@Valid GetUserPasswordReqVO reqVO, BindingResult bindingResult){
|
||||
ResponseEntity<?> operate(@RequestBody @Valid GetUserPasswordReqVO reqVO, BindingResult bindingResult){
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
GetHousehold user = getHouseholdPortIn.operate(new GetHouseholdCmd(CommonUtil.getLoginUsername())).orElseThrow();
|
||||
|
||||
if (!passwordEncoder.matches(reqVO.getPassword(), user.getPassword())) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.failure("INVALID_PASSWORD"));
|
||||
return ResponseEntity.ok(ApiResponse.failure("INVALID_PASSWORD"));
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.success(null));
|
||||
return ResponseEntity.ok(ApiResponse.success(null));
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,14 @@ package app.module.front.usecase.info.user.getUserPasswordUI.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
@NoArgsConstructor // 기본 생성자 자동 추가
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserPasswordReqVO {
|
||||
|
||||
@NotNull(message = "비밀번호는 필수 입력값입니다.")
|
||||
@Pattern(regexp = "\\d{6}", message = "비밀번호는 숫자 6자리여야 합니다.")
|
||||
@Pattern(regexp = "\\d{4}", message = "비밀번호는 숫자 4자리여야 합니다.")
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package app.module.front.usecase.info.user.getUserUI.adapters.web;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.household.getHousehold.ports.GetHouseholdPortIn;
|
||||
import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHouseholdCmd;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@@ -15,7 +18,12 @@ class GetUserUIController {
|
||||
private final GetHouseholdPortIn getHouseholdPortIn;
|
||||
|
||||
@GetMapping(path = "/info/user")
|
||||
String operate(Model model) {
|
||||
String operate(Model model, HttpServletRequest request) {
|
||||
|
||||
String referer = request.getHeader("Referer");
|
||||
if (referer == null || !referer.contains("/info/user/password")) {
|
||||
return "redirect:/"; // 요청 처리 중단
|
||||
}
|
||||
|
||||
model.addAttribute("userInfo",
|
||||
getHouseholdPortIn.operate(new GetHouseholdCmd(CommonUtil.getLoginUsername())).orElseThrow());
|
||||
|
||||
Reference in New Issue
Block a user