Переглянути джерело

임시비밀번호 수정 중

jsshin 5 роки тому
батько
коміт
6ca990bb0a

+ 1 - 0
src/main/java/com/style24/front/biz/dao/TsfCustomerDao.java

@@ -11,4 +11,5 @@ import com.style24.core.support.annotation.ShopDs;
 @ShopDs
 public interface TsfCustomerDao {
 
+
 }

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

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 import com.style24.front.biz.dao.TsfCustomerDao;
 
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 고객(회원) Service
@@ -42,4 +43,29 @@ public class TsfCustomerService {
 		TscSession.setAttribute("maskingYn","Y");
 		return coreCustomerService.getCustomerInfo(customer);
 	}
+
+	/**
+	 * 임시비밀번호 조회
+	 * @param length - 비밀번호 자릿수
+	 * @return 임시비밀번호
+	 * @author jsshin
+	 * @since 2021. 02. 15
+	 */
+	public String getTemporaryPassword(int length) {
+		return coreCustomerService.getTemporaryPassword(length);
+	}
+
+	/**
+	 * 회원 비밀번호 수정
+	 * @param customer - 고객정보
+	 * @author jsshin
+	 * @since 2021. 02. 15
+	 */
+	@Transactional("shopTxnManager")
+	public void saveCustomerPassword(Customer customer) {
+		customer.setTempPasswdYn("Y");
+		coreCustomerService.saveCustomerPassword(customer);
+	}
+
+
 }

+ 85 - 39
src/main/java/com/style24/front/biz/web/TsfCustomerController.java

@@ -1,6 +1,7 @@
 package com.style24.front.biz.web;
 
 import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.security.GagaPasswordEncoder;
 import com.gagaframework.web.util.GagaStringUtil;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.session.TscSession;
@@ -44,6 +45,9 @@ public class TsfCustomerController extends TsfBaseController {
 	@Autowired
 	private NiceCertify niceCertify;
 
+	@Autowired
+	private GagaPasswordEncoder passwordEncoder;
+
 	/**
 	 * 아이디 찾기 화면
 	 *
@@ -61,7 +65,7 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 	/**
-	 * 아이디 찾기
+	 * 아이디 찾기 - 고객정보
 	 *
 	 * @return ModelAndView
 	 * @author jsshin
@@ -69,7 +73,7 @@ public class TsfCustomerController extends TsfBaseController {
 	 */
 	@PostMapping("/id/find")
 	@ResponseBody
-	public GagaMap getIdFind(@RequestBody Customer customer) {
+	public GagaMap getIdFindCustInfo(@RequestBody Customer customer) {
 		GagaMap result = new GagaMap();
 		boolean isFind = false;
 
@@ -79,7 +83,7 @@ public class TsfCustomerController extends TsfBaseController {
 
 		Customer params = new Customer();
 		// 인증방법
-		 GagaMap authInfo = null;
+		 GagaMap authInfo;
 		if (TscConstants.AuthMethod.CUSTINFO.value().equals(customer.getAuthMethod())) {
 			// 기본정보
 			params.setCustNm(customer.getCustNm());
@@ -111,7 +115,6 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 
-
 	/**
 	 * 비밀번호 찾기 화면
 	 *
@@ -129,13 +132,41 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 	/**
-	 * 아이디 찾기
+	 * 비밀번호 찾기 화면 - 아이디 확인
 	 *
-	 * @return ModelAndView
+	 * @param customer - custId
+	 * @return GagaMap - 결과정보
 	 * @author jsshin
-	 * @since 2021. 02. 08
+	 * @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 customer - 고객정보
+	 * @return GagaMap
+	 * @author jsshin
+	 * @since 2021. 02. 15
 	 */
-	@PostMapping("/pwd/find")
+	@PostMapping("/pwd/find/custinfo")
 	@ResponseBody
 	public GagaMap getPwdFind(@RequestBody Customer customer) {
 		GagaMap result = new GagaMap();
@@ -145,30 +176,28 @@ public class TsfCustomerController extends TsfBaseController {
 			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(customer);
 
-		// 고객정보 찾기
-		Customer custInfo = customerService.getCustomerFindId(params);
 		if (custInfo != null) {
 			isFind = true;
-			result.setString("email", custInfo.getEmail());
-			TscSession.setAttribute("custNo", String.valueOf(custInfo.getCustNo()));
+			result.setString("maskingEmail", custInfo.getMaskingEmail());
+		}
+
+		if (isFind) {
+			String tempPasswd = customerService.getTemporaryPassword(10);
+			log.info("tempPasswd  ====> {}", tempPasswd);
+			customer.setTempPasswdYn("Y"); // 임시비밀번호여부
+			customer.setPasswd(tempPasswd);
+			customer.setEncodedPasswd(passwordEncoder.encodeSha256(tempPasswd));
+			customer.setRegNo(custInfo.getCustNo());
+			customer.setUpdNo(custInfo.getCustNo());
+			customer.setCustNo(custInfo.getCustNo());
+
+			// 비밀번호 수정
+			customerService.saveCustomerPassword(customer);
+
+			// TODO: 2021.02.15 메일발송 서비스 붙여야함 - jsshin
 		}
 
 		result.setString("authMethod", customer.getAuthMethod()); // 인증방법
@@ -177,33 +206,50 @@ public class TsfCustomerController extends TsfBaseController {
 	}
 
 	/**
-	 * 비밀번호 찾기 화면 - 아이디 확인
-	 *
-	 * @param customer - custId
-	 * @return GagaMap - 결과정보
+	 * 비밀번호 찾기 - 인증(휴대폰,아이핀)
+	 * @param customer - 고객정보
+	 * @return GagaMap
 	 * @author jsshin
-	 * @since 2021. 02. 10
+	 * @since 2021. 02. 15
 	 */
-	@PostMapping("/id/check")
+	@PostMapping("/pwd/find/certify")
 	@ResponseBody
-	public GagaMap getIdCheck(@RequestBody Customer customer) {
+	public GagaMap getPwdFindCertify(@RequestBody Customer customer) {
 		GagaMap result = new GagaMap();
 		boolean isFind = false;
 
-		if(StringUtils.isBlank(customer.getCustId())) {
-			throw new IllegalStateException("확인 할 아이디가 없습니다.");
+		if (StringUtils.isBlank(customer.getAuthMethod())) {
+			throw new IllegalStateException("인증방법이 없습니다. <br>관리자에게 문의하시기 바랍니다.");
 		}
 
-		Customer custInfo = customerService.getCustomerFindId(customer);
+		Customer params = new Customer();
+		// 인증방법
+		GagaMap authInfo;
+		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;
+			TscSession.setAttribute("custNo", String.valueOf(custInfo.getCustNo()));
 		}
 
+		result.setString("authMethod", customer.getAuthMethod()); // 인증방법
 		result.setBoolean("isFind", isFind);
 		return result;
 	}
 
 
+
+
 	/**
 	 * 비밀번호 찾기 결과 화면
 	 *

+ 6 - 2
src/main/java/com/style24/persistence/mybatis/shop/TsfCustomer.xml

@@ -13,7 +13,11 @@
 		       ) ORIGINAL
 		WHERE  NUMB BETWEEN #{pageable.startRow} AND #{pageable.endRow}
 	</sql>
-	
-	
+
+	<!-- 임시비밀번호 조회 -->
+	<select id="getTemporaryPassword" parameterType="int" resultType="String">
+		/* TsfCustomer.getTemporaryPassword */
+		SELECT CONVERT(TRUNCATE(RAND() * CAST(CONCAT(1,LPAD(0,(#{length} - 1),'0')) AS UNSIGNED),0),CHAR) AS PASSWD FROM DUAL
+	</select>
 
 </mapper>

+ 2 - 60
src/main/webapp/WEB-INF/views/web/customer/FindIdFormWeb.html

@@ -219,6 +219,7 @@
 	</div>
 </div>
 
+<script th:src="@{'/ux/customer/customer.js?v=' + ${#calendars.format(#calendars.createNow(), 'yyyyMMddHHmmss')}}" src="/ux/customer/customer.js"></script>
 <script th:inline="javascript">
 /*<![CDATA[*/
 
@@ -281,14 +282,13 @@
 	// 찾기성공
 	var fnGetDisplaySucc = function (authMethod, custInfo) {
 		$('#resultId').text(custInfo.maskingCustId);
-		$('#joinDt').text(toDateFormat(custInfo.joinDt).replaceAll('-','.'));
+		$('#joinDt').text(fnToDateFormat(custInfo.joinDt));
 		let joinPath = fnSnsJoinPath(custInfo); // 가입경로 : 직접이면 표시 안함, 간편가입 연동 표시
 		if (!gagajf.isNull(joinPath)) {
 			$('#liJoinPath').show();
 			$('#joinPath').text(joinPath);
 		}
 		$('#succeedCustId').show();
-
 	};
 
 	// 찾기실패
@@ -324,64 +324,6 @@
 		return snsType;
 	};
 
-
-	// 이메일 체크
-	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 toDateFormat =  function(value) {
-		if (gagajf.isNull(value))
-			return "";
-		return value.replaceAll("/", "").replaceAll("-", "").toDate("YYYYMMDD").format("YYYY-MM-DD");
-	}
-
-	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('오류로 인해 처리되지 않았습니다.');
-			}
-		});
-	}
-
-
 /*]]>*/
 </script>
 

+ 22 - 62
src/main/webapp/WEB-INF/views/web/customer/FindPwdFormWeb.html

@@ -39,7 +39,7 @@
 					<div class="registration_tap">
 						<div class="form_group" style="display: block;">
 							<!-- 비밀번호찾기일경우 -->
-							<div class="foldGroup checkcase">
+							<div id="searchDiv" class="foldGroup checkcase">
 								<ul>
 									<li>
 										<form id="searchCustInfo" name="searchCustInfo" class="form_wrap" role="form">
@@ -156,14 +156,24 @@
 										<div class="help_block">
 											<!-- 사용불가 비밀번호일경우 -->
 											<p class="mt10">
-												<span class="c_black2"><i class="ico ico_check black mr5"></i>영문(대/소문자), 숫자, 특수문자 중 2가지 이상 조합(8~20자)</span><br>
-												<span class="c_red2"><i class="ico ico_check red mr5"></i>4개이상 연속되거나 동일한 문자/숫자 제외</span><br>
-												<span class="c_gray"><i class="ico ico_check gray mr5"></i>아이디 제외</span>
+												<span class="c_black2">
+													<i class="ico ico_check black mr5"></i>영문(대/소문자), 숫자, 특수문자 중 2가지 이상 조합(8~20자)
+												</span>
+												<br/>
+												<span class="c_red2">
+													<i class="ico ico_check red mr5"></i>4개이상 연속되거나 동일한 문자/숫자 제외
+												</span>
+												<br/>
+												<span class="c_gray">
+													<i class="ico ico_check gray mr5"></i>아이디 제외
+												</span>
 											</p>
 											<!-- //사용불가 비밀번호일경우 -->
 											<!-- 사용가능한 비밀번호일경우 -->
 											<p class="mt10">
-												<span class="c_black2"><i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다</span>
+												<span class="c_black2">
+													<i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다
+												</span>
 											</p>
 											<!-- //사용가능한 비밀번호일경우 -->
 										</div>
@@ -230,6 +240,7 @@
 	</div>
 </div>
 
+<script th:src="@{'/ux/customer/customer.js?v=' + ${#calendars.format(#calendars.createNow(), 'yyyyMMddHHmmss')}}" src="/ux/customer/customer.js"></script>
 <script th:inline="javascript">
 /*<![CDATA[*/
 	let custIdCheck = false;
@@ -278,18 +289,19 @@
 			return;
 		}
 		if (!custIdCheck) {
-			alert('아이디 확인 주세요.');
+			alert('아이디 확인 눌러 주세요.');
 			return;
 		}
 		custInfo.authMethod = 'custInfo';
 
 		let jsonData = JSON.stringify(custInfo);
-		//console.log('jsonData', jsonData);
-		ajaxJsonSubmit('/customer/pwd/find', jsonData, fnInfoConfirmCallBack);
+		console.log('jsonData', jsonData);
+		ajaxJsonSubmit('/customer/pwd/find/custinfo', jsonData, fnInfoConfirmCallBack);
 	});
 
 	// 찾기결과
 	var fnInfoConfirmCallBack = function (result) {
+		console.log('result', result);
 		$('#searchDiv').hide();
 		if (result.isFind) {
 			fnGetDisplaySucc(result.authMethod, result);
@@ -300,8 +312,8 @@
 
 	// 찾기성공
 	var fnGetDisplaySucc = function (authMethod, custInfo) {
-		if (result.authMethod === 'custInfo') {
-			$('#sendEmail').text(result.email)
+		if (custInfo.authMethod === 'custInfo') {
+			$('#sendEmail').text(custInfo.maskingEmail)
 			$('#divSendEmail').show();
 		}
 
@@ -320,58 +332,6 @@
 		}
 	};
 
-
-	// 이메일 체크
-	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();
 	let password = $('#password').val();

+ 18 - 6
src/main/webapp/WEB-INF/views/web/customer/FindPwdResultFormWeb.html

@@ -44,14 +44,24 @@
 								<div class="help_block">
 									<!-- 사용불가 비밀번호일경우 -->
 									<p class="mt10">
-										<span class="c_black2"><i class="ico ico_check black mr5"></i>영문(대/소문자), 숫자, 특수문자 중 2가지 이상 조합(8~20자)</span><br>
-										<span class="c_red2"><i class="ico ico_check red mr5"></i>4개이상 연속되거나 동일한 문자/숫자 제외</span><br>
-										<span class="c_gray"><i class="ico ico_check gray mr5"></i>아이디 제외</span>
+										<span class="c_black2">
+											<i class="ico ico_check black mr5"></i>영문(대/소문자), 숫자, 특수문자 중 2가지 이상 조합(8~20자)
+										</span>
+										<br/>
+										<span class="c_red2">
+											<i class="ico ico_check red mr5"></i>4개이상 연속되거나 동일한 문자/숫자 제외
+										</span>
+										<br/>
+										<span class="c_gray">
+											<i class="ico ico_check gray mr5"></i>아이디 제외
+										</span>
 									</p>
 									<!-- //사용불가 비밀번호일경우 -->
 									<!-- 사용가능한 비밀번호일경우 -->
 									<p class="mt10">
-										<span class="c_black2"><i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다</span>
+										<span class="c_black2">
+											<i class="ico ico_check black mr5"></i>사용 가능한 비밀번호입니다
+										</span>
 									</p>
 									<!-- //사용가능한 비밀번호일경우 -->
 								</div>
@@ -61,7 +71,7 @@
 						<div class="form_field">
 							<label class="input_label sr-only">비밀번호 확인</label>
 							<div class="ui_col_12">
-								<input type="password" name="userConfirm" placeholder="비밀번호 확인" id="txtConfirm">
+								<input type="password" name="password" placeholder="비밀번호 확인"/>
 								<!-- case (비밀번호확인 틀렸을경우,비밀번호 일치할경우) -->
 								<div class="help_block">
 									<!-- 비밀번호확인 틀렸을경우 -->
@@ -82,7 +92,9 @@
 						</div>
 						<div class="btn_group_block btn_group_md ui_row">
 							<div class="ui_col_12">
-								<button class="btn btn_dark btn_block"><span>변경 후 다시 로그인</span></button>
+								<button class="btn btn_dark btn_block">
+									<span>변경 후 다시 로그인</span>
+								</button>
 							</div>
 						</div>
 					</div>

+ 88 - 0
src/main/webapp/ux/customer/customer.js

@@ -0,0 +1,88 @@
+/**
+ *******************************************************************************
+ * @source  : customer.js
+ * @desc    : 회원(고객) 공통 JS
+ *============================================================================
+ * STYLE24
+ * Copyright(C) 2021 TSIT, All rights reserved.
+ *============================================================================
+ * VER  DATE         AUTHOR      DESCRIPTION
+ * ===  ===========  ==========  =============================================
+ * 1.0  2021.02.15   jsshin     최초 작성
+ *******************************************************************************
+ */
+
+
+/**
+ * 이메일 유효성 체크
+ * @param email - 이메일
+ * @return boolean - 통과(true)/실패(fail)
+ * @author jsshin
+ * @since 2021. 02. 15
+ */
+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;
+};
+
+
+/**
+ * 날짜 변환 YYYYMMDD -> YYYY.MM.DD
+ * @param date - 날짜
+ * @return string - YYYY.MM.DD
+ * @author jsshin
+ * @since 2021. 02. 15
+ */
+var fnToDateFormat =  function(date) {
+	if (gagajf.isNull(date))
+		return "";
+	return date.replaceAll("/", "").replaceAll("-", "").toDate("YYYYMMDD").format("YYYY.MM.DD");
+}
+
+/*
+* 임시사용
+*
+* */
+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('오류로 인해 처리되지 않았습니다.');
+		}
+	});
+}