Explorar o código

비밀번호변경 추가

gagamel %!s(int64=5) %!d(string=hai) anos
pai
achega
09d32cb174

+ 2 - 2
style24.scm/src/main/java/com/style24/persistence/domain/User.java

@@ -32,8 +32,8 @@ public class User extends TscBaseDomain {
 	private String roleRefVal;
 	private String supplyCompCd;
 	private String supplyCompNm;
-	private String photoCompCd;
-	private String photoCompNm;
+//	private String photoCompCd;
+//	private String photoCompNm;
 	private String email;
 	private String cellPhnno;
 	private String ipAddr;

+ 41 - 6
style24.scm/src/main/java/com/style24/persistence/mybatis/shop/TssLogin.xml

@@ -21,12 +21,12 @@
 		                 WHERE  SUPPLY_COMP_CD = A.ROLE_REF_VAL
 		                )
 		       END                                       AS SUPPLY_COMP_NM /*공급업체명*/
-		     , CASE WHEN SUBSTRING(REPLACE(ROLE_CD,'G001_', ''),1,1) = 'E' THEN
-		                ROLE_REF_VAL
-		       END                                       AS PHOTO_COMP_CD  /*촬영업체코드*/
-		     , CASE WHEN SUBSTRING(ROLE_CD,1,1) = 'E' THEN
-		                FN_GET_CODE_NM('G003',ROLE_REF_VAL)
-		       END                                       AS PHOTO_COMP_NM  /*촬영업체명*/
+		     -- , CASE WHEN SUBSTRING(REPLACE(ROLE_CD,'G001_', ''),1,1) = 'E' THEN
+		     --            ROLE_REF_VAL
+		     --   END                                       AS PHOTO_COMP_CD  /*촬영업체코드*/
+		     -- , CASE WHEN SUBSTRING(ROLE_CD,1,1) = 'E' THEN
+		     --            FN_GET_CODE_NM('G003',ROLE_REF_VAL)
+		     --   END                                       AS PHOTO_COMP_NM  /*촬영업체명*/
 		     , EMAIL                                                       /*이메일*/
 		     , CELL_PHNNO                                                  /*휴대전화번호*/
 		     , IP_ADDR                                                     /*IP주소*/
@@ -188,5 +188,40 @@
 		WHERE  MENU_ID NOT LIKE 'P%' /*팝업메뉴제외*/
 		ORDER  BY DISP_ORD
 	</select>
+	
+	<!-- 비밀번호 수정 -->
+	<update id="updatePassword" parameterType="User">
+		/* TsaSystem.updatePassword */
+		UPDATE TB_USER
+		SET    PASSWD = #{passwd}
+		     , UPD_NO = #{updNo}
+		     , UPD_DT = NOW()
+		WHERE  USER_NO = #{userNo}
+	</update>
+	
+	<!-- 사용자정보변경이력 생성 -->
+	<insert id="createUserInfoChangeHistory" parameterType="UserHst">
+		/* TssLogin.createUserInfoChangeHistory */
+		INSERT INTO TB_USER_HST (
+		       CHG_HST_SQ
+		     , USER_NO
+		     , CHG_GB
+		     , CHG_CONTENT
+		     , REG_NO
+		     , REG_DT
+		)
+		VALUES (
+		       NULL
+		     , #{userNo}
+		     , #{chgGb}
+		     , CASE WHEN #{chgGb} = 'G049_20' THEN
+		                CONCAT(FN_GET_CODE_NM('G001',#{orgRoleCd}),' -> ',FN_GET_CODE_NM('G001',#{roleCd}))
+		            ELSE
+		                NULL
+		       END
+		     , #{regNo}
+		     , NOW()
+		)
+	</insert>
 
 </mapper>

+ 84 - 68
style24.scm/src/main/java/com/style24/scm/biz/dao/TssLoginDao.java

@@ -1,68 +1,84 @@
-package com.style24.scm.biz.dao;
-
-import java.util.Collection;
-
-import com.style24.core.support.annotation.ShopDs;
-import com.style24.persistence.domain.Menu;
-import com.style24.persistence.domain.User;
-
-/**
- * 로그인 Dao
- * @author gagamel
- * @since 2020. 10. 19
- */
-@ShopDs
-public interface TssLoginDao {
-
-	/**
-	 * ID로 사용자 정보 조회
-	 * @param userId - 사용자ID
-	 * @return
-	 * @author gagamel
-	 * @since 2020. 10. 5
-	 */
-	User getUserById(String userId);
-
-	/**
-	 * 로그인실패 남기기
-	 * @param user - 사용자정보
-	 * @author gagamel
-	 * @date 2020. 10. 5
-	 */
-	void createLoginFail(User user);
-
-	/**
-	 * 로그인 실패건수 조회
-	 * @param user - 사용자정보
-	 * @return 로그인 실패건수
-	 * @author gagamel
-	 * @date 2020. 10. 5
-	 */
-	int getLoginFailCount(User user);
-
-	/**
-	 * 최종로그인일시 Update
-	 * @param userNo - 사용자번호
-	 * @author gagamel
-	 * @since 2020. 10. 5
-	 */
-	void updateLastLoginDate(Integer userNo);
-
-	/**
-	 * 로그인이력 남기기
-	 * @param user - 사용자정보
-	 * @author gagamel
-	 * @date 2020. 10. 5
-	 */
-	void createLoginHistory(User user);
-
-	/**
-	 * 로그인 메뉴 목록
-	 * @param userNo - 사용자번호
-	 * @return
-	 * @author gagamel
-	 * @since 2020. 10. 5
-	 */
-	Collection<Menu> getLoginMenuList(Integer userNo);
-
-}
+package com.style24.scm.biz.dao;
+
+import java.util.Collection;
+
+import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.Menu;
+import com.style24.persistence.domain.User;
+import com.style24.persistence.domain.UserHst;
+
+/**
+ * 로그인 Dao
+ * @author gagamel
+ * @since 2020. 10. 19
+ */
+@ShopDs
+public interface TssLoginDao {
+
+	/**
+	 * ID로 사용자 정보 조회
+	 * @param userId - 사용자ID
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 10. 5
+	 */
+	User getUserById(String userId);
+
+	/**
+	 * 로그인실패 남기기
+	 * @param user - 사용자정보
+	 * @author gagamel
+	 * @date 2020. 10. 5
+	 */
+	void createLoginFail(User user);
+
+	/**
+	 * 로그인 실패건수 조회
+	 * @param user - 사용자정보
+	 * @return 로그인 실패건수
+	 * @author gagamel
+	 * @date 2020. 10. 5
+	 */
+	int getLoginFailCount(User user);
+
+	/**
+	 * 최종로그인일시 Update
+	 * @param userNo - 사용자번호
+	 * @author gagamel
+	 * @since 2020. 10. 5
+	 */
+	void updateLastLoginDate(Integer userNo);
+
+	/**
+	 * 로그인이력 남기기
+	 * @param user - 사용자정보
+	 * @author gagamel
+	 * @date 2020. 10. 5
+	 */
+	void createLoginHistory(User user);
+
+	/**
+	 * 로그인 메뉴 목록
+	 * @param userNo - 사용자번호
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 10. 5
+	 */
+	Collection<Menu> getLoginMenuList(Integer userNo);
+
+	/**
+	 * 비밀번호 수정
+	 * @param user - 사용자 정보
+	 * @since 2020. 12. 28
+	 */
+	void updatePassword(User user);
+
+	/**
+	 * 사용자정보변경이력 생성
+	 * @param userHst - 사용자이력 정보
+	 * @author gagamel
+	 * @since 2020. 12. 28
+	 */
+	void createUserInfoChangeHistory(UserHst userHst);
+
+}

+ 17 - 0
style24.scm/src/main/java/com/style24/scm/biz/service/TssLoginService.java

@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
 import com.style24.core.biz.thirdparty.SsgKakaoSender;
 import com.style24.persistence.domain.Menu;
 import com.style24.persistence.domain.User;
+import com.style24.persistence.domain.UserHst;
 import com.style24.scm.biz.dao.TssLoginDao;
 import com.style24.scm.support.security.session.TssSession;
 
@@ -137,4 +138,20 @@ public class TssLoginService {
 		TssSession.setAttribute("tfcertno", certNo);
 	}
 
+	/**
+	 * 사용자 비밀번호 수정
+	 * @param user - 사용자 정보
+	 * @since 2020. 10. 7
+	 */
+	public void updatePassword(User user) {
+		loginDao.updatePassword(user);
+
+		// 사용자정보변경이력 생성 - 비밀번호변경
+		UserHst userHst = new UserHst();
+		userHst.setUserNo(user.getUserNo());
+		userHst.setChgGb("G049_30"); // 비밀번호변경
+		userHst.setRegNo(TssSession.getInfo().getUserNo());
+		loginDao.createUserInfoChangeHistory(userHst);
+	}
+
 }

+ 42 - 0
style24.scm/src/main/java/com/style24/scm/biz/web/TssIndexController.java

@@ -7,11 +7,13 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
 import com.style24.core.support.message.TscMessageByLocale;
+import com.style24.persistence.domain.User;
 import com.style24.scm.biz.service.TssLoginService;
 import com.style24.scm.support.controller.TssBaseController;
 import com.style24.scm.support.security.session.TssSession;
@@ -19,6 +21,7 @@ import com.style24.scm.support.security.session.TssSession;
 import lombok.extern.slf4j.Slf4j;
 
 import com.gagaframework.web.rest.server.GagaResponse;
+import com.gagaframework.web.security.GagaPasswordEncoder;
 
 /**
  * Index Controller
@@ -36,6 +39,9 @@ public class TssIndexController extends TssBaseController {
 	@Autowired
 	private TssLoginService loginService;
 
+	@Autowired
+	private GagaPasswordEncoder passwordEncoder;
+
 	/**
 	 * 첫 페이지
 	 * 		로그인 하고
@@ -111,4 +117,40 @@ public class TssIndexController extends TssBaseController {
 		return super.ok(message.getMessage("SUCC_0005"));
 	}
 
+	/**
+	 * 비밀번호 변경 팝업
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 12. 28
+	 */
+	@GetMapping("/password/change/form")
+	public ModelAndView passwordChangeForm() {
+		ModelAndView mav = new ModelAndView();
+
+		mav.setViewName("PasswordChangeForm");
+
+		return mav;
+	}
+
+	/**
+	 * 비밀번호 변경 처리
+	 * @param user - 사용자 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 12. 28
+	 */
+	@PostMapping("/password/change")
+	@ResponseBody
+	public GagaResponse changePassword(@RequestBody User user) {
+		user.setUserNo(TssSession.getInfo().getUserNo());
+		user.setPasswd(passwordEncoder.encode(user.getPasswd()));
+		user.setUpdNo(TssSession.getInfo().getUserNo());
+		log.info("user: {}", user);
+
+		// 비밀번호 수정
+		loginService.updatePassword(user);
+
+		return super.ok(message.getMessage("SUCC_0009"));
+	}
+
 }

+ 101 - 0
style24.scm/src/main/webapp/WEB-INF/views/PasswordChangeForm.html

@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<html lang="ko"
+	xmlns:th="http://www.thymeleaf.org">
+<!--
+ *******************************************************************************
+ * @source  : PasswordChangeForm.html
+ * @desc    : 비밀번호 변경 팝업 Page
+ *============================================================================
+ * STYLE24
+ * Copyright(C) 2020 TSIT, All rights reserved.
+ *============================================================================
+ * VER  DATE         AUTHOR      DESCRIPTION
+ * ===  ===========  ==========  =============================================
+ * 1.0  2020.12.28   gagamel     최초 작성
+ *******************************************************************************
+ -->
+<div class="modalPopup" data-width="500" id="popupPasswordChange">
+	<div class="panelStyle">
+		<!-- TITLE -->
+		<div class="panelTitle">
+			<strong>비밀번호 변경</strong>
+			<button type="button" class="close" onclick="uifnPopupClose('popupPasswordChange');"><em class="fa fa-times"></em></button>
+		</div>
+		<!-- //TITLE -->
+		
+		<!-- CONTENT -->
+		<div class="panelContent">
+			<form name="popupPasswordForm" id="popupPasswordForm" action="#" th:action="@{'/password/change'}" th:method="post">
+				<table class="frmStyle" aria-describedby="변경폼">
+					<colgroup>
+						<col style="width:10%;"/>
+						<col/>
+					</colgroup>
+					<tbody>
+						<tr>
+							<th>사용자ID<em class="required" title="필수"></em></th>
+							<td th:text="${sessionInfo.userId}">
+							</td>
+						</tr>
+						<tr>
+							<th>비밀번호<em class="required" title="필수"></em></th>
+							<td>
+								<input type="password" class="w300" name="passwd" data-valid-type="password" required="required" data-valid-name="비밀번호"/>
+							</td>
+						</tr>
+						<tr>
+							<th>비밀번호 확인<em class="required" title="필수"></em></th>
+							<td>
+								<input type="password" class="w300" name="passwdConfirm" data-valid-type="password" required="required" data-valid-name="비밀번호 확인"/>
+							</td>
+						</tr>
+					</tbody>
+				</table>
+				<p class="dot cBlue">대문자, 소문자, 특수문자, 숫자로 구성해야 합니다.</p>
+				<p class="dot cBlue">이 중 3개 이상은 8 ~ 20자, 2개 이상은 10 ~ 20자로 설정해야 합니다.</p>
+			</form>
+		</div>
+		<!-- //CONTENT -->
+		
+		<!-- 버튼 배치 영역 -->
+		<ul class="panelBar">
+			<li class="right">
+				<button type="button" class="btn btn-info btn-lg" id="btnPasswordChange">저장</button>
+			</li>
+		</ul>
+		<!-- //버튼 배치 영역 -->
+	</div>
+</div>
+
+<script th:inline="javascript">
+/*<![CDATA[*/
+	$('#btnPasswordChange').on('click', function() {
+		if (!gagajf.validation('#popupPasswordForm'))
+			return false;
+		
+		var pwd = $('#popupPasswordForm input[name="passwd"]').val();
+		var pwdConfirm = $('#popupPasswordForm input[name="passwdConfirm"]').val();
+		
+		if (pwd != pwdConfirm) {
+			mcxDialog.alert('비밀번호를 확인해주세요.');
+			return;
+		}
+		
+		mcxDialog.confirm("비밀번호를 변경하시겠습니까?", {
+			cancelBtnText: "취소",
+			sureBtnText: "확인",
+			sureBtnClick: function() {
+				gagajf.ajaxFormSubmit($('#popupPasswordForm').prop('action'), '#popupPasswordForm', function() {
+					uifnPopupClose('popupPasswordChange');
+				});
+			}
+		});
+	});
+	
+	$(document).ready(function() {
+
+	});
+/*]]>*/
+</script>
+
+</html>

+ 6 - 1
style24.scm/src/main/webapp/WEB-INF/views/common/fragments/gnb.html

@@ -43,7 +43,7 @@
 			<i class="dot">&bull;</i>
 			<a th:text="${sessionInfo.roleNm}">Director</a>
 			<i class="dot">&bull;</i>
-			<a th:onclick="|cfnPasswordChange();|">비밀번호 변경</a>
+			<a href="#" th:onclick="|fnOpenPasswordChangePopup();|">비밀번호 변경</a>
 			<i class="dot">&bull;</i>
 			<a href="#" th:href="@{/logout}">Log out</a>
 		</div>
@@ -82,6 +82,11 @@
 		cfnDrawLnbMenu($(a).data('menuId'));
 	});
 	
+	// 비밀번호 변경 팝업
+	var fnOpenPasswordChangePopup = function() {
+		cfnOpenModalPopup('/password/change/form', 'popupPasswordChange');
+	}
+	
 	$(document.body).ready(function() {
 		// 로그인메뉴목록 설정
 		cfnSetLoginMenuList([[${loginMenuList}]]);