Просмотр исходного кода

비밀번호 찾기 개발 중

jsshin 5 лет назад
Родитель
Сommit
9c3868c42f

+ 0 - 1
src/main/java/com/style24/front/biz/service/TsfCustomerService.java

@@ -63,7 +63,6 @@ public class TsfCustomerService {
 	 */
 	@Transactional("shopTxnManager")
 	public void saveCustomerPassword(Customer customer) {
-		customer.setTempPasswdYn("Y");
 		coreCustomerService.saveCustomerPassword(customer);
 	}
 

+ 35 - 0
src/main/java/com/style24/front/biz/web/TsfCustomerController.java

@@ -249,6 +249,41 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 
+	/**
+	 * 비밀번호 변경
+	 *
+	 * @param customer - 비밀번호 정보
+	 * @return ModelAndView
+	 * @author jsshin
+	 * @since 2021. 02. 16
+	 */
+	@PostMapping("/password/reset")
+	public GagaMap resetPassword(@RequestParam Customer customer) {
+		GagaMap result = new GagaMap();
+		String custNo = TscSession.getAttribute("custNo");
+		if (StringUtils.isBlank(custNo)) {
+			throw new IllegalStateException("고객 정보가 없습니다. 다시 확인 해주세요.");
+		}
+		Customer params = new Customer();
+		params.setCustNo(Integer.valueOf(custNo));
+
+		// 고객정보 찾기
+		Customer custInfo = customerService.getCustomerFindId(params);
+
+		if (custInfo != null) {
+			customer.setTempPasswdYn("N"); // 임시비밀번호여부
+			customer.setEncodedPasswd(passwordEncoder.encodeSha256(customer.getPasswd()));
+			customer.setRegNo(custInfo.getCustNo());
+			customer.setUpdNo(custInfo.getCustNo());
+			customer.setCustNo(custInfo.getCustNo());
+			// 비밀번호 수정
+			customerService.saveCustomerPassword(customer);
+		}
+
+		return result;
+	}
+
+
 
 
 	/**

+ 21 - 115
src/main/webapp/WEB-INF/views/web/customer/FindPwdFormWeb.html

@@ -153,7 +153,7 @@
 									<div class="form_field mt40">
 										<label class="input_label sr-only">신규 비밀번호</label>
 										<div class="ui_col_12">
-											<input type="password" id="password" name="password" placeholder="신규 비밀번호" >
+											<input type="password" id="passwd" name="passwd" placeholder="신규 비밀번호" minlength="8" maxlength="20"/>
 											<!-- case (사용불가 비밀번호일경우,사용가능한 비밀번호일경우) -->
 											<div class="help_block">
 												<!-- 사용불가 비밀번호일경우 -->
@@ -170,9 +170,9 @@
 												</p>
 												<!-- //사용불가 비밀번호일경우 -->
 												<!-- 사용가능한 비밀번호일경우 -->
-												<p class="mt10 hide">
-													<span id="avlPwd" class="c_black2">
-														<i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다
+												<p id="avlPwd" class="mt10 hide">
+													<span class="c_black2">
+														<i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다.
 													</span>
 												</p>
 												<!-- //사용가능한 비밀번호일경우 -->
@@ -183,7 +183,7 @@
 									<div class="form_field">
 										<label class="input_label sr-only">비밀번호 확인</label>
 										<div class="ui_col_12">
-											<input type="password" id="confirmPassword" name="confirmPassword" placeholder="비밀번호 확인">
+											<input type="password" id="confirmPassword" name="confirmPassword" placeholder="비밀번호 확인" minlength="8" maxlength="20"/>
 											<!-- case (비밀번호확인 틀렸을경우,비밀번호 일치할경우) -->
 											<div class="help_block">
 												<!-- 비밀번호확인 틀렸을경우 -->
@@ -204,7 +204,7 @@
 									</div>
 									<div class="btn_group_block btn_group_md ui_row">
 										<div class="ui_col_12">
-											<button type="button" id="btnSavePassword" class="btn btn_dark btn_block">
+											<button type="button" id="btnSavePassword" class="btn btn_dark btn_block" disabled="disabled">
 												<span>변경 후 다시 로그인</span>
 											</button>
 										</div>
@@ -370,123 +370,29 @@
 	};
 
 	// 패스워드 입력
-	$("#resetPasswordForm input[name=password]").on('focus focusout keyup keydown', function () {
-		let password = $(this).val();
-		fnCheckPassword(password)
+	$('#resetPasswordForm input[name=passwd]').on('focus focusout keyup keydown', function () {
+		fnCheckPassword('#resetPasswordForm');
 	});
 
+	// 패스워드 확인 입력
+	$('#resetPasswordForm input[name=confirmPassword]').on('focus focusout keyup keydown', function () {
+		fnConfirmPassword('#resetPasswordForm');
+	});
 
-	var fnCheckPassword = function (password) {
-		let custId = $('#resetPasswordForm input[name=custId]').val();
-		let $firstFailed = $('#firstFailed');
-		let $secondFailed = $('#secondFailed');
-		let $thirdFailed = $('#thirdFailed');
-		let $avlPwd = $('#avlPwd');
-		let pwdCheck = true;
-
-		// 길이
-		if(!/^[a-zA-Z0-9!@#$%^&*()?_~]{8,20}$/.test(password)) {
-			$firstFailed.show();
-			pwdCheck = false;
-		} else {
-			$firstFailed.hide();
-			pwdCheck = true;
-		}
-
-		// 영문, 숫자, 특수문자 2종 이상 혼용
-		let count = 0;
-		if(password.search(/[0-9]/g) != -1 ) count ++;
-		if(password.search(/[a-zA-Z]/ig)  != -1 ) count ++;
-		if(password.search(/[!@#$%^&*()?_~]/g)  != -1  ) count ++;
-		if(count < 2) {
-			$firstFailed.show();
-			pwdCheck = false;
-		} else {
-			$firstFailed.hide();
-			pwdCheck = true;
-		}
-
-		// 동일한 문자/숫자 4이상, 연속된 문자
-		if(/(\w)\1\1\1/.test(password) || isContinuedValue(password)) {
-			$secondFailed.show();
-			pwdCheck = false;
-		} else {
-			$secondFailed.hide();
-			pwdCheck = true;
-		}
-
-		// 아이디 포함 여부
-		if(password.search(custId)>-1) {
-			$thirdFailed.show();
-			pwdCheck = false;
-		} else {
-			$thirdFailed.hide();
-			pwdCheck = true;
-		}
-
-		if (pwdCheck) {
-			$avlPwd.show();
-		} else {
-			$avlPwd.hide();
-		}
-
+	// 패스워드 저장
+	$('#btnSavePassword').on('click', function () {
+		let resetPasswordForm = $('#resetPasswordForm').serializeObject();
+		fnCheckPassword('#resetPasswordForm');
+		fnConfirmPassword('#resetPasswordForm');
+		let jsonData = JSON.stringify(resetPasswordForm);
+		ajaxJsonSubmit('/customer/password/reset', jsonData, fnSavePasswordCallback);
+	});
 
-	}
+	var fnSavePasswordCallback = function (result) {
 
-	var fnConfirmPassword = function () {
-		let $misPwd = $('#misPwd');
-		let $avlConPwd = $('#avlConPwd');
-		let password = $("#resetPasswordForm input[name=password]").val();
-		let confirmPassword = $('#confirmPassword').val();
-		// 재입력 일치 여부
-		if (password != confirmPassword) {
-			$avlConPwd.hide();
-			$misPwd.show()
-		} else {
-			$misPwd.hide();
-			$avlConPwd.show();
-		}
 	}
 
-	// 연속되는 문자
-	var isContinuedValue = function (password) {
-		console.log("password = " + password);
-		var intCnt1 = 0;
-		var intCnt2 = 0;
-		var temp0 = "";
-		var temp1 = "";
-		var temp2 = "";
-		var temp3 = "";
-
-		for (var i = 0; i < password.length-3; i++) {
-			console.log("=========================");
-			temp0 = password.charAt(i);
-			temp1 = password.charAt(i + 1);
-			temp2 = password.charAt(i + 2);
-			temp3 = password.charAt(i + 3);
-
-			console.log(temp0)
-			console.log(temp1)
-			console.log(temp2)
-			console.log(temp3)
-
-			if (temp0.charCodeAt(0) - temp1.charCodeAt(0) == 1
-				&& temp1.charCodeAt(0) - temp2.charCodeAt(0) == 1
-				&& temp2.charCodeAt(0) - temp3.charCodeAt(0) == 1) {
-				intCnt1 = intCnt1 + 1;
-			}
 
-			if (temp0.charCodeAt(0) - temp1.charCodeAt(0) == -1
-				&& temp1.charCodeAt(0) - temp2.charCodeAt(0) == -1
-				&& temp2.charCodeAt(0) - temp3.charCodeAt(0) == -1) {
-				intCnt2 = intCnt2 + 1;
-			}
-			console.log("=========================");
-		}
-
-		console.log(intCnt1 > 0 || intCnt2 > 0);
-		return (intCnt1 > 0 || intCnt2 > 0);
-	}
 
 
 /*]]>*/

+ 132 - 1
src/main/webapp/ux/customer/customer.js

@@ -29,7 +29,6 @@ var fnCheckValidationEmail = function (email) {
 	return result;
 };
 
-
 /**
  * 날짜 변환 YYYYMMDD -> YYYY.MM.DD
  * @param date - 날짜
@@ -41,8 +40,140 @@ var fnToDateFormat =  function(date) {
 	if (gagajf.isNull(date))
 		return "";
 	return date.replaceAll("/", "").replaceAll("-", "").toDate("YYYYMMDD").format("YYYY.MM.DD");
+};
+
+/**
+ * 비밀번호 유효성 체크
+ * input name이 custId, password, confirmpassword  동일해야 이 매소드를 사용 할수 있음
+ * 실패 텍스트는 아래에 있는 id 값으로 해야함
+ * @param form 넘김
+ * @author jsshin
+ * @since 2021. 02. 16
+ */
+var fnCheckPassword = function (form) {
+	let custId = $(form + ' input[name=custId]').val();
+	let password = $(form  +' input[name=passwd]').val();
+	let confirmPassword = $(form  + ' input[name=confirmPassword]').val();
+	let $firstFailed = $('#firstFailed');
+	let $secondFailed = $('#secondFailed');
+	let $thirdFailed = $('#thirdFailed');
+	let $avlPwd = $('#avlPwd');
+	let pwdCheck = true;
+
+	// 길이
+	if(!/^[a-zA-Z0-9!@#$%^&*()?_~]{8,20}$/.test(password)) {
+		pwdCheck = false;
+		$firstFailed.show();
+	} else {
+		$firstFailed.hide();
+	}
+
+	// 영문, 숫자, 특수문자 2종 이상 혼용
+	let count = 0;
+	if(password.search(/[0-9]/g) != -1 ) count ++;
+	if(password.search(/[a-zA-Z]/ig)  != -1 ) count ++;
+	if(password.search(/[!@#$%^&*()?_~]/g)  != -1  ) count ++;
+	if(count < 2) {
+		pwdCheck = false;
+		$firstFailed.show();
+	} else {
+		$firstFailed.hide();
+	}
+
+	// 동일한 문자/숫자 4이상, 연속된 문자
+	if(/(\w)\1\1\1/.test(password) || isContinuedValue(password)) {
+		pwdCheck = false;
+		$secondFailed.show();
+	} else {
+		$secondFailed.hide();
+	}
+
+	// 아이디 포함 여부
+	if(password.search(custId) > -1) {
+		pwdCheck = false;
+		$thirdFailed.show();
+	} else {
+		$thirdFailed.hide();
+	}
+
+	// 사용 가능한 비밀번호인지
+	if (pwdCheck) {
+		$avlPwd.show();
+	} else {
+		$avlPwd.hide();
+	}
+
+	if (!gagajf.isNull(confirmPassword)) {
+		fnConfirmPassword(form);
+	}
+
+};
+
+/**
+ * 확인 비밀번호 유효성 체크
+ * input name이 custId, password, confirmpassword  동일해야 이 매소드를 사용 할수 있음
+ * 실패 텍스트는 아래에 있는 id 값으로 해야함
+ * @param form 넘김
+ * @author jsshin
+ * @since 2021. 02. 16
+ */
+var fnConfirmPassword = function (form) {
+	let password = $(form  +' input[name=passwd]').val();
+	let confirmPassword = $(form  + ' input[name=confirmPassword]').val();
+	let $misPwd = $('#misPwd');
+	let $avlConPwd = $('#avlConPwd');
+	let $btnSavePassword = $('#btnSavePassword');
+
+	// 재입력 일치 여부
+	if (password != confirmPassword) {
+		$avlConPwd.hide();
+		$misPwd.show();
+		$btnSavePassword.attr('disabled', true);
+	} else {
+		$misPwd.hide();
+		$avlConPwd.show();
+		$btnSavePassword.attr('disabled', false);
+	}
 }
 
+/**
+ * 연속되는 문자가 있는지 확인
+ * @param form 넘김
+ * @return true/false
+ * @author jsshin
+ * @since 2021. 02. 16
+ */
+var isContinuedValue = function (password) {
+	var intCnt1 = 0;
+	var intCnt2 = 0;
+	var temp0 = "";
+	var temp1 = "";
+	var temp2 = "";
+	var temp3 = "";
+
+	for (var i = 0; i < password.length-3; i++) {
+		temp0 = password.charAt(i);
+		temp1 = password.charAt(i + 1);
+		temp2 = password.charAt(i + 2);
+		temp3 = password.charAt(i + 3);
+
+		if (temp0.charCodeAt(0) - temp1.charCodeAt(0) == 1
+			&& temp1.charCodeAt(0) - temp2.charCodeAt(0) == 1
+			&& temp2.charCodeAt(0) - temp3.charCodeAt(0) == 1) {
+			intCnt1 = intCnt1 + 1;
+		}
+
+		if (temp0.charCodeAt(0) - temp1.charCodeAt(0) == -1
+			&& temp1.charCodeAt(0) - temp2.charCodeAt(0) == -1
+			&& temp2.charCodeAt(0) - temp3.charCodeAt(0) == -1) {
+			intCnt2 = intCnt2 + 1;
+		}
+
+	}
+	return (intCnt1 > 0 || intCnt2 > 0);
+}
+
+
 /*
 * 임시사용
 *