Browse Source

관리자, 의료진 초기화비밀번호 수정, 초기화비밀번호 로그인시 정보변경페이지 이동

huiwon.seo 4 years ago
parent
commit
994f3325fa

+ 15 - 0
src/main/java/com/lemon/lifecenter/common/LifeCenterInterCeptor.java

@@ -29,6 +29,7 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
         Object session  = request.getSession().getAttribute( "sesId" );
         Object groupIdx = request.getSession().getAttribute( "sesGroupIdx" );
         Object sesMId   = request.getSession().getAttribute( "sesMId" );
+        Object sesPasswordChange = request.getSession().getAttribute( "sesPasswordChange" );
         
         logger.info( "|------------------------------------------------------------------|" );
         logger.info( "|  URL : " + url + "  |  IP : " + LifeCenterFunction.getRemoteAddr(request) + "  |  Port : " + port );
@@ -66,6 +67,20 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
                     return false;
                 } else {
                     logger.info( "IP : " + LifeCenterFunction.getRemoteAddr( request ) + " ID : " + session.toString() + "  URL : " + url + " Port : " + port );
+                    
+                    if( sesPasswordChange != null && sesPasswordChange.equals( "true" ) ) {
+                        
+                        if( !url.equals( "/staff/myinfo" ) ) {
+                            logger.info( "초기화 비밀번호로 로그인 -> 비밀번호 변경 페이지로 이동" );
+                            
+                            if( !url.equals( "/common/passwordCheck" ) && !url.equals( "/staff/myinfo/update" ) ) {
+                                LifeCenterFunction.scriptMessage( response, "location.href='/staff/myinfo';" );
+                            }
+                        } else {
+                            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '초기화 비밀번호로 로그인시 비밀번호 변경 후 서비스 이용이 가능합니다.', callBack : function(){  } });" );
+                        }
+                        
+                    }
                 }
                 
             } else if( url.equals( "/login/staff" ) || url.equals( "/login/admin" ) ) {

+ 9 - 1
src/main/java/com/lemon/lifecenter/controller/LoginController.java

@@ -63,7 +63,8 @@ public class LoginController extends LifeCenterController {
         JSONObject json = new JSONObject();
         
 //        dto.setPassword( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, dto.getPassword() ) );
-        dto.setPassword( LifeCenterFunction.sha256Encrypt(dto.getPassword()) );
+        String passwordVal = dto.getPassword();
+        dto.setPassword( LifeCenterFunction.sha256Encrypt( passwordVal ) );
         
         int total = loginService.selectMemberCount( dto );
         
@@ -132,10 +133,17 @@ public class LoginController extends LifeCenterController {
                 LifeCenterSessionController.setSession( request, "sesGroupIdx", String.valueOf( memberData.getGroupIdx() ) );
                 LifeCenterSessionController.setSession( request, "sesPhoneNumber", String.valueOf( memberData.getPhoneNumber() ) );
                 
+                
                 url = "/patient/list";
                 if( memberData.getGroupIdx() == 1 ) {
                     url = "/center/list";
                 }
+                
+                // 로그인시 초기화 비밀번호일 경우 비밀번호 변경 페이지로 이동
+                if( passwordVal.equals( config.staffResetPw ) || passwordVal.equals( config.centerResetPw ) ) {
+                    LifeCenterSessionController.setSession( request, "sesPasswordChange", "true" );
+                    url = "/staff/myinfo";
+                }
             }
         }
         

+ 11 - 2
src/main/java/com/lemon/lifecenter/controller/StaffController.java

@@ -211,7 +211,7 @@ public class StaffController extends LifeCenterController {
         return mv;
     }
     
-    @RequestMapping("myinfo/update")
+    @RequestMapping( value="myinfo/update", method=RequestMethod.POST)
     public String myInfoUpdate(
             HttpServletRequest request, HttpServletResponse response,
             @ModelAttribute("dto") final StaffDTO dto,
@@ -219,6 +219,7 @@ public class StaffController extends LifeCenterController {
             @RequestParam(value="passwordConfirm", required=false, defaultValue="") String passwordConfirm,
             @RequestParam(value="returnUrl", required=false, defaultValue="") String returnUrl) throws Exception {
         
+        Object sesPasswordChange = request.getSession().getAttribute( "sesPasswordChange" );
         String encryptPw = LifeCenterFunction.sha256Encrypt(dto.getPassword());
         dto.setPassword(encryptPw);
         
@@ -231,12 +232,20 @@ public class StaffController extends LifeCenterController {
             }
             memberService.updateMember(dto);
             LifeCenterSessionController.setSession( request, "sesName", dto.getName() );
+            
+            if( sesPasswordChange != null && sesPasswordChange.equals( "true" ) ) {
+                LifeCenterSessionController.setSession( request, "sesPasswordChange", "false" );
+            }
+            
+            LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '변경되었습니다', callBack : function(){ location.href='/staff/myinfo'; } });" );
+            return "/common/blank";
         } else {
             LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '비밀번호가 일치하지않습니다.', callBack : function(){ history.back(); } });" );
             return "/common/blank";
         }
         
-        return "redirect:" + returnUrl;
+        
+//        return "redirect:/";
 //        return "redi"returnUrl;
     }
 

+ 4 - 2
src/main/resources/config.properties

@@ -5,8 +5,10 @@ config.aesKey             =   1q2w3e4r5t6y7u8i9o0p!@#$%^&*()hj
 config.pageGroupSize      = 5
 config.pageDataSize       = 10
 config.pagePrefix         = page
-config.staff.resetPw      = doc1234!
-config.center.resetPw     = admin1234!
+
+config.staff.resetPw      = D3o$c!5aH
+config.center.resetPw     = C3t$r!5aH
+
 config.nonface.api.token  = https://lemon.medihere.com/auth/token
 config.nonface.api.appVC  = https://lemon.medihere.com/app/vc
 config.nonface.api.key    = 94e1ab361de9b8ca057c84c19cf1d907

+ 6 - 6
src/main/webapp/WEB-INF/jsp/center/new.jsp

@@ -34,9 +34,9 @@ $( function(){
                 phoneValid : true
             },
             staffPw : {
-                minlength : 8,
-                maxlength : 15,
-                passwordValid : true
+//                 minlength : 8,
+//                 maxlength : 15,
+                passwordCheck : true
             },
             staffPwConfirm : {
                 equalTo: "#staffPw",
@@ -55,8 +55,8 @@ $( function(){
                 remote : "이미 존재하는 아이디입니다"
             },
             staffPw : {
-                minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
-                maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
+//                 minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
+//                 maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
             },
             staffPwConfirm : {
                 equalTo: "비밀번호가 일치하지 않습니다.",
@@ -201,7 +201,7 @@ $( function(){
                                                 <th><span class="fix">*</span>비밀번호</th>
                                                 <td colspan="3">
 <!--                                                 placeholder="숫자, 영문, 특수문자 조합 8~15자 이내" -->
-                                                    <input type="password" class="form-control" name="staffPw" id="staffPw" maxlength="15" required>
+                                                    <input type="password" class="form-control" name="staffPw" id="staffPw" maxlength="15" placeholder="최소 8자리 이상의 (대문자, 소문자, 숫자, 특수문자) 2가지 종류 이상의 조합 or 10자리 이상의 비밀번호" required>
                                                 </td>
                                             </tr>
                                             <tr>

+ 3 - 3
src/main/webapp/WEB-INF/jsp/staff/myinfo.jsp

@@ -15,7 +15,7 @@ $( function(){
                  equalTo: "#passwordNew"
             },
             passwordNew :{
-                passwordValid : true
+                passwordCheck : true
             }
         },
         messages : {
@@ -65,7 +65,7 @@ $( function(){
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <form action="./myinfo/update" id="newForm">
+                                <form action="./myinfo/update" id="newForm" method="post">
                                 <input type="hidden" value="${returnUrl}" name="returnUrl">
                                     <div class="card-body">
                                         <table class="table mobile-table">
@@ -97,7 +97,7 @@ $( function(){
                                             <tr>
                                                 <th>신규 비밀번호</th>
                                                 <td colspan="3">
-                                                    <input type="password" class="form-control" id="passwordNew" name="passwordNew" placeholder="비밀번호 변경시에만 입력해주세요.(영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)">
+                                                    <input type="password" class="form-control" id="passwordNew" name="passwordNew" maxlength="15" placeholder="최소 8자리 이상의 (대문자, 소문자, 숫자, 특수문자) 2가지 종류 이상의 조합 or 10자리 이상의 비밀번호">
                                                 </td>
                                             </tr>
                                             <tr>

+ 7 - 7
src/main/webapp/WEB-INF/jsp/staff/new.jsp

@@ -30,9 +30,9 @@ $( function(){
                 phoneValid : true
             },
             password : {
-                minlength : 8,
-                maxlength : 15,
-                passwordValid : true
+//                 minlength : 8,
+//                 maxlength : 15,
+                passwordCheck : true
             },
             passwordConfirm : {
                 equalTo: "#password",
@@ -43,8 +43,8 @@ $( function(){
                 remote : "이미 존재하는 아이디입니다"
             },
             password : {
-                minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
-                maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
+//                 minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
+//                 maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
             },
             passwordConfirm : {
                 equalTo: "비밀번호가 일치하지 않습니다.",
@@ -116,13 +116,13 @@ $( function(){
                                             <tr>
                                                 <th><span class="fix">*</span>비밀번호</th>
                                                 <td colspan="3">
-                                                    <input type="password" id="password" class="form-control pass-group" name="password" placeholder="비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)" required>
+                                                    <input type="password" id="password" class="form-control pass-group" name="password" maxlength="15" placeholder="최소 8자리 이상의 (대문자, 소문자, 숫자, 특수문자) 2가지 종류 이상의 조합 or 10자리 이상의 비밀번호" required>
                                                 </td>
                                             </tr>
                                             <tr>
                                                 <th><span class="fix">*</span>비밀번호 확인</th>
                                                 <td colspan="3">
-                                                    <input type="password" id="passwordConfirm" class="form-control" name="passwordConfirm" placeholder="비밀번호 확인을 위해 비밀번호를 한번 더 입력하세요." required>
+                                                    <input type="password" id="passwordConfirm" class="form-control" name="passwordConfirm" maxlength="15" placeholder="비밀번호 확인을 위해 비밀번호를 한번 더 입력하세요." required>
                                                 </td>
                                             </tr>
                                             <tr>

+ 1 - 1
src/main/webapp/resources/js/common/common.js

@@ -7,7 +7,7 @@ $(function(){
     
     $.validator.addMethod( "passwordCheck",  function( value, element ) {
         var valid = false;
-        var errorMsg = "최소 8자리 이상 (대문자, 소문자, 숫자, 특수문자) 2가지 종류 이상의 조합 or 10자리 이상의 비밀번호";
+        var errorMsg = "최소 8자리 이상 (대문자, 소문자, 숫자, 특수문자) 2가지 종류 이상의 조합 or 10자리 이상의 비밀번호";
         
         $.ajax({
             url      : "/common/passwordCheck",