Explorar o código

비밀번호 수정 중

jsshin %!s(int64=5) %!d(string=hai) anos
pai
achega
1ac081c474

+ 128 - 54
src/main/java/com/style24/front/biz/web/TsfCustomerController.java

@@ -110,6 +110,131 @@ public class TsfCustomerController extends TsfBaseController {
 		return result;
 	}
 
+
+
+	/**
+	 * 비밀번호 찾기 화면
+	 *
+	 * @return ModelAndView
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
+	@GetMapping("/pwd/find/form")
+	public ModelAndView pwdFindForm() {
+		ModelAndView mav = new ModelAndView();
+
+		mav.setViewName(super.getDeviceViewName("customer/FindPwdForm"));
+
+		return mav;
+	}
+
+	/**
+	 * 아이디 찾기
+	 *
+	 * @return ModelAndView
+	 * @author jsshin
+	 * @since 2021. 02. 08
+	 */
+	@PostMapping("/pwd/find")
+	@ResponseBody
+	public GagaMap getPwdFind(@RequestBody Customer customer) {
+		GagaMap result = new GagaMap();
+		boolean isFind = false;
+
+		if (StringUtils.isBlank(customer.getAuthMethod())) {
+			throw new IllegalStateException("인증방법이 없습니다. <br>관리자에게 문의하시기 바랍니다.");
+		}
+
+		Customer params = new Customer();
+		// 인증방법
+		GagaMap authInfo = null;
+		if (TscConstants.AuthMethod.CUSTINFO.value().equals(customer.getAuthMethod())) {
+			// 기본정보
+			params.setCustId(customer.getCustId());
+			params.setCustNm(customer.getCustNm());
+			params.setEmail(customer.getEmail());
+		} else if (TscConstants.AuthMethod.MOBILE.value().equals(customer.getAuthMethod())) {
+			// 핸드폰 인증
+			authInfo = niceCertify.getCertifyCellPhoneResultInfo(customer);
+			params.setCi(authInfo.getString("sCi"));
+		} else if (TscConstants.AuthMethod.IPIN.value().equals(customer.getAuthMethod())) {
+			// 아이핀
+			authInfo = niceCertify.getCertifyIpinResultInfo(customer);
+			params.setCi(authInfo.getString("sConnInfo"));
+		}
+
+		// 고객정보 찾기
+		Customer custInfo = customerService.getCustomerFindId(params);
+		if (custInfo != null) {
+			isFind = true;
+			result.setString("email", custInfo.getEmail());
+			TscSession.setAttribute("custNo", String.valueOf(custInfo.getCustNo()));
+		}
+
+		result.setString("authMethod", customer.getAuthMethod()); // 인증방법
+		result.setBoolean("isFind", isFind);
+		return result;
+	}
+
+	/**
+	 * 비밀번호 찾기 화면 - 아이디 확인
+	 *
+	 * @param customer - custId
+	 * @return GagaMap - 결과정보
+	 * @author jsshin
+	 * @since 2021. 02. 10
+	 */
+	@PostMapping("/id/check")
+	@ResponseBody
+	public GagaMap getIdCheck(@RequestBody Customer customer) {
+		GagaMap result = new GagaMap();
+		boolean isFind = false;
+
+		if(StringUtils.isBlank(customer.getCustId())) {
+			throw new IllegalStateException("확인 할 아이디가 없습니다.");
+		}
+
+		Customer custInfo = customerService.getCustomerFindId(customer);
+		if (custInfo != null) {
+			isFind = true;
+		}
+
+		result.setBoolean("isFind", isFind);
+		return result;
+	}
+
+
+	/**
+	 * 비밀번호 찾기 결과 화면
+	 *
+	 * @param confirmYn - 인증여부
+	 * @return ModelAndView
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
+	@GetMapping("/pwd/find/result/form")
+	public ModelAndView pwdFindResult(@RequestParam(required = false) String confirmYn) {
+		ModelAndView mav = new ModelAndView();
+
+		mav.setViewName(super.getDeviceViewName("customer/FindPwdResultForm"));
+		return mav;
+	}
+
+	/**
+	 * 회원정보 입력 화면
+	 *
+	 * @return ModelAndView
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
+	@GetMapping("/join/form")
+	public ModelAndView getJoinForm() {
+		ModelAndView mav = new ModelAndView();
+
+		mav.setViewName(super.getDeviceViewName("customer/JoinForm"));
+		return mav;
+	}
+
 	/**
 	 * 휴대폰 인증 화면
 	 * @param redirectUrl - 모바일사용
@@ -124,7 +249,7 @@ public class TsfCustomerController extends TsfBaseController {
 		ModelAndView mav = new ModelAndView();
 		GagaMap result = niceCertify.certifyCellPhone();
 
-		if ("M".equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl); // 모바일만 사용
 		}
 
@@ -146,8 +271,7 @@ public class TsfCustomerController extends TsfBaseController {
 		ModelAndView mav = new ModelAndView();
 		GagaMap result = niceCertify.certifyIpin();
 
-
-		if ("M".equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl); // 모바일만 사용
 		}
 
@@ -182,7 +306,7 @@ public class TsfCustomerController extends TsfBaseController {
 			authMethod = TscConstants.AuthMethod.IPIN.value();
 		}
 
-		if ("M".equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl);
 		}
 
@@ -193,54 +317,4 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 
-	/**
-	 * 비밀번호 찾기 화면
-	 *
-	 * @return ModelAndView
-	 * @author jsshin
-	 * @since 2021. 02. 05
-	 */
-	@RequestMapping("/pwd/find/form")
-	public ModelAndView pwdFindForm() {
-		ModelAndView mav = new ModelAndView();
-
-		mav.setViewName(super.getDeviceViewName("customer/FindPwdForm"));
-
-		return mav;
-	}
-
-
-	/**
-	 * 비밀번호 찾기 결과 화면
-	 *
-	 * @param confirmYn - 인증여부
-	 * @return ModelAndView
-	 * @author jsshin
-	 * @since 2021. 02. 05
-	 */
-	@GetMapping("/pwd/find/result/form")
-	public ModelAndView pwdFindResult(@RequestParam(required = false) String confirmYn) {
-		ModelAndView mav = new ModelAndView();
-
-		mav.setViewName(super.getDeviceViewName("customer/FindPwdResultForm"));
-		return mav;
-	}
-
-	/**
-	 * 회원정보 입력 화면
-	 *
-	 * @return ModelAndView
-	 * @author jsshin
-	 * @since 2021. 02. 05
-	 */
-	@GetMapping("/join/form")
-	public ModelAndView getJoinForm() {
-		ModelAndView mav = new ModelAndView();
-
-		mav.setViewName(super.getDeviceViewName("customer/JoinForm"));
-		return mav;
-	}
-
-
-
 }

+ 143 - 4
src/main/webapp/WEB-INF/views/web/customer/FindPwdFormWeb.html

@@ -42,7 +42,7 @@
 							<div class="foldGroup checkcase">
 								<ul>
 									<li>
-										<form class="form_wrap" role="form">
+										<form id="searchCustInfo" name="searchCustInfo" class="form_wrap" role="form">
 											<div class="fold_head">
 												<a href="javascript:void(0)">
 													<div>
@@ -60,8 +60,8 @@
 													<label class="input_label sr-only">아이디</label>
 													<div class="ui_col_12">
 														<div class="input_wrap">
-															<input type="text" name="custId" placeholder="아이디" id="txtId" class="form_control" maxlength="30"/>
-															<button type="button" class="btn btn_primary">
+															<input type="text" id="custId" name="custId" placeholder="아이디" class="form_control" maxlength="30"/>
+															<button type="button" id="btnSearchId" class="btn btn_primary">
 																<span>확인</span>
 															</button>
 														</div>
@@ -211,7 +211,7 @@
 									</p>
 								</div>
 								<div class="form_print_bar mt40">
-									<p class="c_primary bold" data-font="lato">a****c@gmail.com</p>
+									<p id="sendEmail" class="c_primary bold" data-font="lato"></p>
 								</div>
 								<div class="btn_group_block btn_group_md ui_row">
 									<div class="ui_col_12">
@@ -232,6 +232,145 @@
 
 <script th:inline="javascript">
 /*<![CDATA[*/
+	let custIdCheck = false;
+
+	// 아이디 확인
+	$('#btnSearchId').on('click', function () {
+		let custId = $('#custId').val();
+		if(gagajf.isNull(custId)) {
+			alert("아이디를 입력해주세요.");
+			return;
+		}
+		let custInfo = {};
+		custInfo.custId = custId;
+		let jsonData = JSON.stringify(custInfo);
+		ajaxJsonSubmit('/customer/id/check', jsonData, fnIdConfirmCallBack)
+	});
+
+	var fnIdConfirmCallBack = function (result) {
+		if (result.isFind) {
+			custIdCheck = true;
+		} else {
+			alert("입력하신 아이디는 STYLE24 회원이 아닙니다. \n 다시 확인해주세요.");
+		}
+	};
+
+	$('#btnInfoConfirm').on('click', function () {
+		let custInfo = $('#searchCustInfo').serializeObject();
+
+		if(gagajf.isNull(custInfo.custId)) {
+			alert("아이디를 입력해주세요.");
+			return;
+		}
+
+		if (gagajf.isNull(custInfo.custNm)) {
+			alert('이름을 형식에 맞게 입력해주세요.');
+			return;
+		}
+
+		if (gagajf.isNull(custInfo.email)) {
+			alert('이메일을 입력하여 주세요.');
+			return;
+		}
+
+		if (!fnCheckValidationEmail(custInfo.email)) {
+			alert('이메일 형식에 맞게 입력해주세요.');
+			return;
+		}
+		if (!custIdCheck) {
+			alert('아이디 확인 해주세요.');
+			return;
+		}
+		custInfo.authMethod = 'custInfo';
+
+		let jsonData = JSON.stringify(custInfo);
+		//console.log('jsonData', jsonData);
+		ajaxJsonSubmit('/customer/pwd/find', jsonData, fnInfoConfirmCallBack);
+	});
+
+	// 찾기결과
+	var fnInfoConfirmCallBack = function (result) {
+		$('#searchDiv').hide();
+		if (result.isFind) {
+			fnGetDisplaySucc(result.authMethod, result);
+		} else {
+			fnGetDisplayFail(result.authMethod);
+		}
+	};
+
+	// 찾기성공
+	var fnGetDisplaySucc = function (authMethod, custInfo) {
+		if (result.authMethod === 'custInfo') {
+			$('#sendEmail').text(result.email)
+			$('#divSendEmail').show();
+		}
+
+
+	};
+
+	// 찾기실패
+	var fnGetDisplayFail = function (authMethod) {
+		$('.form_head').hide();
+		$('.registration_nav').hide();
+		if (authMethod === 'custInfo') {
+			$('#failCustId').show();
+		}
+		if (authMethod === 'mobile' || authMethod === 'ipin') {
+			$('#failAuthentication').show();
+		}
+	};
+
+
+	// 이메일 체크
+	var fnCheckValidationEmail = function (email) {
+		const regexp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
+		let result = true;
+		if (!regexp.test(email)) {
+			result = false;
+		}
+		return result;
+	};
+
+	var ajaxJsonSubmit = function (url, json, callback) {
+		$.ajax({
+			type : "POST",
+			url : url,
+			dataType : 'json',
+			data : json,
+			beforeSend : function(xhr, opts) { // 통신 전
+				// when validation is false
+				// AJAX call
+				xhr.setRequestHeader('AJAX', 'true');
+				// dataType: "json"일 때
+				xhr.setRequestHeader('Accept', 'application/json');
+				xhr.setRequestHeader('Content-Type', 'application/json');
+			},
+			success : function(result) {
+				if (typeof(result.status) == 'undefined' || result.status === 200) { // 성공
+					if (!gagajf.isNull(result.message)) {
+						if (alert(result.message)) {
+							if (typeof(callback) === 'function') {
+								callback.call(this, result);
+							}
+						}
+					} else {
+						if (typeof(callback) == "function") {
+							callback.call(this, result);
+						}
+					}
+				} else { // 실패
+					if (!gagajf.isNull(result.error.message)) {
+						alert(result.error.message);
+					}
+				}
+			},
+			error : function() {
+				// error code
+				alert('오류로 인해 처리되지 않았습니다.');
+			}
+		});
+	}
+
 
 var fnCheckPassword = function () {
 	let custId = $('#custId').val();