diff --git a/src/main/java/com/dbnt/faisp/config/SecurityConfig.java b/src/main/java/com/dbnt/faisp/config/SecurityConfig.java index 3206f04e..6afd900a 100644 --- a/src/main/java/com/dbnt/faisp/config/SecurityConfig.java +++ b/src/main/java/com/dbnt/faisp/config/SecurityConfig.java @@ -61,9 +61,9 @@ public class SecurityConfig{ http.authorizeRequests() // 페이지 권한 설정 .antMatchers("/file/**", "/board/**", "/info/**").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용 .antMatchers("/admin/**").hasRole(Role.ADMIN.name()) // ADMIN만 접근 허용 - .antMatchers("/user/login").permitAll() // 로그인 페이지는 권한 없이 접근 허용 + .antMatchers("/login").permitAll() // 로그인 페이지는 권한 없이 접근 허용 .and() // 로그인 설정 - .formLogin() .loginPage("/user/login") // Custom login form 사용 + .formLogin() .loginPage("/login") // Custom login form 사용 .failureUrl("/login-error") // 로그인 실패 시 이동 .defaultSuccessUrl("/") // 로그인 성공 시 redirect 이동 .and() // 로그아웃 설정 diff --git a/src/main/java/com/dbnt/faisp/controller/BaseController.java b/src/main/java/com/dbnt/faisp/controller/BaseController.java index 80d70d38..99869e59 100644 --- a/src/main/java/com/dbnt/faisp/controller/BaseController.java +++ b/src/main/java/com/dbnt/faisp/controller/BaseController.java @@ -20,7 +20,7 @@ public class BaseController { public ModelAndView loginCheck(@AuthenticationPrincipal UserInfo loginUser, HttpSession session) { ModelAndView mav = null; if(loginUser == null){ - mav = new ModelAndView("redirect:/user/login"); + mav = new ModelAndView("redirect:/login"); }else{ session.setAttribute("positionList", commonCodeService.selectCommonCodeValue("POSITION")); session.setAttribute("departmentList", commonCodeService.selectCommonCodeValue("DEPARTMENT")); @@ -39,15 +39,15 @@ public class BaseController { session.setAttribute("departmentList", commonCodeService.selectCommonCodeValue("DEPARTMENT")); } - @GetMapping("/user/login") + @GetMapping("/login") public ModelAndView goLogin() { - ModelAndView mav = new ModelAndView("login"); + ModelAndView mav = new ModelAndView("/login/login"); return mav; } @GetMapping("/login-error") public ModelAndView loginError() { - ModelAndView mav = new ModelAndView("/login"); + ModelAndView mav = new ModelAndView("/login/login"); mav.addObject("loginError", true); return mav; } diff --git a/src/main/resources/static/css/login/login.css b/src/main/resources/static/css/login/login.css index 7a3a662e..2f403a20 100644 --- a/src/main/resources/static/css/login/login.css +++ b/src/main/resources/static/css/login/login.css @@ -9,7 +9,7 @@ top: 50%; left: 50%; transform: translate(-50%, -50%); - border-radius: 20px; + border-radius: 10px; } header{ diff --git a/src/main/resources/static/js/login/login.js b/src/main/resources/static/js/login/login.js new file mode 100644 index 00000000..d213f286 --- /dev/null +++ b/src/main/resources/static/js/login/login.js @@ -0,0 +1,79 @@ + + +$(document).on('click', '#saveBtn', function (){ + if(valueCheck("userInfoInsert")){ + if(confirm("저장하시겠습니까?")){ + contentFade("in"); + const formData = new FormData($("#userInfoInsert")[0]); + debugger + $.ajax({ + type : 'POST', + data : formData, + url : "/admin/insertUserInfo", + processData: false, + contentType: false, + success : function(result) { + if(result === "userIdDuplication"){ + alert("등록된 아이디입니다.") + }else{ + alert("저장되었습니다.") + $("#closeModalBtn").click(); + $("#searchBtn").click(); + } + contentFade("out"); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); + } + }) + } + } +}) + +function valueCheck(form){ + const targetForm = $("#"+form); + const userId = targetForm.find("#userId").val(); + const password = targetForm.find("#modalPassword"); + const passwordConfirm = targetForm.find("#passwordConfirm"); + const name = targetForm.find("#name").val() + let returnFlag = true; + + if(!userId){ + alert("아이디를 입력해주세요."); + returnFlag = false; + }else{ + const idReg = /^[a-z]+[a-z0-9]{5,19}$/g; + if(!idReg.test(userId)){ + returnFlag = false; + alert("아이디 조건이 맞지 않습니다.") + } + } + if(!password[0].disabled && !password.val()){ + alert("비밀번호를 입력해주세요."); + returnFlag = false; + } + if(!password[0].disabled && !passwordConfirm.val()){ + alert("비밀번호 확인을 입력해주세요."); + returnFlag = false; + } + if(!name){ + alert("이름 입력해주세요."); + returnFlag = false; + } + if(returnFlag){ + const passwordReg = /^(?=.*[a-zA-z])(?=.*[0-9])(?=.*[$`~!@$!%*#^?&\\(\\)\-_=+]).{8,16}$/; + if(!password[0].disabled){ + if(!passwordReg.test(password.val())){ + alert("비밀번호 조건이 맞지 않습니다.") + returnFlag = false; + }else{ + if(password.val() !== passwordConfirm.val()){ + alert("비밀번호가 같지 않습니다."); + returnFlag = false; + } + } + } + } + return returnFlag; +} \ No newline at end of file diff --git a/src/main/resources/templates/layout/layout.html b/src/main/resources/templates/layout/layout.html index f4d792e4..0bdf6ff6 100644 --- a/src/main/resources/templates/layout/layout.html +++ b/src/main/resources/templates/layout/layout.html @@ -39,8 +39,7 @@ /*세션 체크*/ const positionList = '[[${session.positionList}]]'; const departmentList = '[[${session.departmentList}]]'; - const categoryList = '[[${session.categoryList}]]'; - if(!positionList && !departmentList && !categoryList) { + if(!positionList && !departmentList) { sessionReload() } }) diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html deleted file mode 100644 index 37f9638a..00000000 --- a/src/main/resources/templates/login.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - -
- 배경2 -
- -
- - - -

로그인에 실패하였습니다.

- - - - -

로그인

-
- - -
-
- - -
- - -
-
-
- \ No newline at end of file diff --git a/src/main/resources/templates/login/login.html b/src/main/resources/templates/login/login.html new file mode 100644 index 00000000..e1278238 --- /dev/null +++ b/src/main/resources/templates/login/login.html @@ -0,0 +1,102 @@ + + + + + + + + +
+ 배경2 +
+ +
+

반갑습니다

+

이곳은 외사정보시스템입니다

+
+
+ + + +

로그인에 실패하였습니다.

+ + +
+ +
+ +
+ +
+ +
+
+ + + +
+
+ + +
+ \ No newline at end of file