diff --git a/pom.xml b/pom.xml
index bbaa712..15b3649 100644
--- a/pom.xml
+++ b/pom.xml
@@ -200,7 +200,12 @@
tiles-servlet
${org.apache.tiles.version}
-
+
+ org.apache.commons
+ commons-email
+ 1.5
+
+
diff --git a/src/main/java/com/mca/cmmn/mapper/UserCertificationMapper.java b/src/main/java/com/mca/cmmn/mapper/UserCertificationMapper.java
new file mode 100644
index 0000000..ca29e9e
--- /dev/null
+++ b/src/main/java/com/mca/cmmn/mapper/UserCertificationMapper.java
@@ -0,0 +1,13 @@
+package com.mca.cmmn.mapper;
+
+import com.mca.cmmn.vo.UserCertificationVO;
+import egovframework.rte.psl.dataaccess.mapper.Mapper;
+
+@Mapper("userCertificationMapper")
+public interface UserCertificationMapper {
+ void insertCertificationNum(UserCertificationVO certificationVO);
+
+ UserCertificationVO selectCertificationInfo(UserCertificationVO certificationVO);
+
+ void updateCertificationNumStatus(UserCertificationVO certificationVO);
+}
diff --git a/src/main/java/com/mca/cmmn/service/UserCertificationService.java b/src/main/java/com/mca/cmmn/service/UserCertificationService.java
new file mode 100644
index 0000000..8bfee50
--- /dev/null
+++ b/src/main/java/com/mca/cmmn/service/UserCertificationService.java
@@ -0,0 +1,58 @@
+package com.mca.cmmn.service;
+
+import com.mca.cmmn.mapper.UserCertificationMapper;
+import com.mca.cmmn.vo.UserCertificationVO;
+import com.mca.user.vo.UserVO;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.SimpleEmail;
+import org.springframework.mail.MailException;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Random;
+
+@Service("userCertificationService")
+public class UserCertificationService {
+
+ @Resource(name = "userCertificationMapper")
+ UserCertificationMapper userCertificationMapper;
+
+ public String sendCertificationNumber(UserVO user) throws MailException {
+ Random random = new Random(System.currentTimeMillis());
+ int range = (int)Math.pow(10,6);
+ int trim = (int)Math.pow(10, 6-1);
+ int certificationNumber = random.nextInt(range)+trim;
+
+ UserCertificationVO userCertificationVO = new UserCertificationVO();
+ userCertificationVO.setUserid(user.getUserid());
+ userCertificationVO.setCertification_num(Integer.toString(certificationNumber));
+ userCertificationVO.setExpiration_date(LocalDateTime.now().plusMinutes(5));
+ userCertificationMapper.insertCertificationNum(userCertificationVO);
+
+ SimpleEmail email = new SimpleEmail();
+ email.setCharset("euc-kr");
+ email.setHostName("smtp.naver.com");
+ email.setSmtpPort(587);
+ email.setAuthentication("lcks0504l", "nocm509");
+ try {
+ email.addTo(user.getEmail(), user.getName());
+ email.setFrom("lcks0504l@naver.com", "[지하공간]인증번호 발송");
+ email.setSubject("[지하공간]인증번호 발송");
+ email.setContent("인증번호 : "+certificationNumber, "text/plain; charset=euc-kr");
+ email.send();
+ } catch (EmailException e) {
+ e.printStackTrace();
+ return "mailError";
+ }
+ return "mailSend";
+ }
+
+ public UserCertificationVO selectCertificationInfo(UserCertificationVO certificationVO) {
+ return userCertificationMapper.selectCertificationInfo(certificationVO);
+ }
+
+ public void updateCertificationNumStatus(UserCertificationVO certificationVO) {
+ userCertificationMapper.updateCertificationNumStatus(certificationVO);
+ }
+}
diff --git a/src/main/java/com/mca/cmmn/vo/UserCertificationVO.java b/src/main/java/com/mca/cmmn/vo/UserCertificationVO.java
new file mode 100644
index 0000000..16d9181
--- /dev/null
+++ b/src/main/java/com/mca/cmmn/vo/UserCertificationVO.java
@@ -0,0 +1,44 @@
+package com.mca.cmmn.vo;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class UserCertificationVO {
+
+ private String userid;
+ private String certification_num;
+ private LocalDateTime expiration_date;
+ private String status;
+
+ public String getUserid() {
+ return userid;
+ }
+
+ public void setUserid(String userid) {
+ this.userid = userid;
+ }
+
+ public String getCertification_num() {
+ return certification_num;
+ }
+
+ public void setCertification_num(String certification_num) {
+ this.certification_num = certification_num;
+ }
+
+ public LocalDateTime getExpiration_date() {
+ return expiration_date;
+ }
+
+ public void setExpiration_date(LocalDateTime expiration_date) {
+ this.expiration_date = expiration_date;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+}
diff --git a/src/main/java/com/mca/cmmn/web/CommonController.java b/src/main/java/com/mca/cmmn/web/CommonController.java
index ee1b290..1677d7d 100644
--- a/src/main/java/com/mca/cmmn/web/CommonController.java
+++ b/src/main/java/com/mca/cmmn/web/CommonController.java
@@ -1,10 +1,13 @@
package com.mca.cmmn.web;
+import java.time.LocalDateTime;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
+import com.mca.cmmn.service.UserCertificationService;
+import com.mca.cmmn.vo.UserCertificationVO;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@@ -17,218 +20,224 @@ import egovframework.rte.fdl.property.EgovPropertyService;
@Controller
public class CommonController {
-
-
- /**
- * properties값을 가져오는 인터페이스.
- **/
- @Resource(name="propertiesService")
- private EgovPropertyService propertiesService;
-
- @Resource(name="userService")
- private UserService userService;
-
- @Resource(name="areaCodeService")
- private AreaCodeService areaCodeService;
-
-
- /**
- * 로그인 화면을 반환한다.
- *
- * @param error 로그인 실패정보
- * @param fail 사용자 인증정보
- * @return 로그인화면 화면
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/login")
- public String login(String error, String fail, Model model) throws Exception{
- try {
- if(error != null) {
- model.addAttribute("errMsg", "접속자 정보를 찾을 수 없습니다.");
- }
- if(fail != null) {
- model.addAttribute("errMsg", "승인 처리중입니다.");
- }
- return "login";
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- return "error/EgovServerError";
- }
- }
-
- /**
- * 로그아웃처리를 한다
- *
- * @param session 세션 객체
- * @param model 모델 객체
- * @return 로그인 화면
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/logout")
- public String logout(HttpSession session, Model model) throws Exception {
- try {
- session.removeAttribute("id");
- session.removeAttribute("admin");
- model.addAttribute("url", "/");
- model.addAttribute("resultMsg", "로그아웃 되었습니다.");
- return "/redirect";
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- return "error/EgovServerError";
- }
- }
-
- /**
- * 회원가입 화면을 반환한다.
- * @return 회원가입 화면
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/join")
- public String join() throws Exception {
- try {
- return "anonymous/html/join";
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- return "error/EgovServerError";
- }
- }
-
- /**
- * 아이디 중복 체크를 한다.
- * @param checkId 입력 아이디값
- * @return 성공, 실패 여부
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/userIdCheck")
- @ResponseBody
- public String checkId(@RequestParam("checkId")String checkId) throws Exception {
- try {
- int cnt = userService.selectUserIdCheck(checkId);
- if(cnt > 0) {
- return "duplicate";
- }else {
- return "ok";
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- return "error/EgovServerError";
- }
- }
-
- /**
- * 사용자 등록 처리를 한다.
- * @param userVO 사용자정보 VO
- * @param model 모델 객체
- * @return 로그인 화면
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/insertUser")
- public String userInsert(@ModelAttribute("userVO") UserVO userVO, Model model) throws Exception {
- try {
- int result = userService.insertUser(userVO);
- if(result == 0) {
- model.addAttribute("url", "/");
- model.addAttribute("resultMsg", "회원가입이 완료 되었습니다. 승인을 기다려주세요.");
- return "/redirect";
- }else {
- model.addAttribute("resultMsg", "오류가 발생하였습니다.");
- return null;
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- return "error/EgovServerError";
- }
- }
-
- /**
- * 지역 리스트 가져온다.
- * @param code 법정동 코드
- * @param area 지역이름
- * @return 선택된 지역 리스트
- * @throws Exception 기본 예외 처리
- */
- @RequestMapping(value="/selectAreaList")
- @ResponseBody
- public List> selectAreaList(@RequestParam("code")String code, @RequestParam("area")String area) throws Exception {
- List> countyList = areaCodeService.selectCounty(code, area);
- return countyList;
- }
-
- /**
- * 권한이 없는 사용자가 접근시 권한제한 화면으로 이동한다.
- *
- * @return 권한없음 페이지
- * @exception Exception 기본 예외 처리
- */
- @RequestMapping("/error/EgovAccessDenied")
- public String accessDenied() throws Exception {
- return "error/EgovAccessDenied";
+
+
+ /**
+ * properties값을 가져오는 인터페이스.
+ **/
+ @Resource(name="propertiesService")
+ private EgovPropertyService propertiesService;
+
+ @Resource(name="userService")
+ private UserService userService;
+
+ @Resource(name="areaCodeService")
+ private AreaCodeService areaCodeService;
+
+ @Resource(name="userCertificationService")
+ private UserCertificationService userCertificationService;
+
+
+ /**
+ * 로그인 화면을 반환한다.
+ *
+ * @param error 로그인 실패정보
+ * @param fail 사용자 인증정보
+ * @return 로그인화면 화면
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/login")
+ public String login(String error, String fail, Model model) throws Exception{
+ try {
+ if(error != null) {
+ model.addAttribute("errMsg", "접속자 정보를 찾을 수 없습니다.");
+ }
+ if(fail != null) {
+ model.addAttribute("errMsg", "승인 처리중입니다.");
+ }
+ return "login";
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ return "error/EgovServerError";
}
-// 아이디 찾기 페이지 이동
- @RequestMapping(value = "findId")
- public String findIdView(){
+ }
- return "anonymous/findId";
- }
- // 아이디 찾기 실행
+ /**
+ * 로그아웃처리를 한다
+ *
+ * @param session 세션 객체
+ * @param model 모델 객체
+ * @return 로그인 화면
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/logout")
+ public String logout(HttpSession session, Model model) throws Exception {
+ try {
+ session.removeAttribute("id");
+ session.removeAttribute("admin");
+ model.addAttribute("url", "/");
+ model.addAttribute("resultMsg", "로그아웃 되었습니다.");
+ return "/redirect";
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ return "error/EgovServerError";
+ }
+ }
- @RequestMapping(value = "findId", method = RequestMethod.POST)
- public String findIdAction(UserVO userVO, Model model) {
- UserVO user = userService.findId(userVO);
+ /**
+ * 회원가입 화면을 반환한다.
+ * @return 회원가입 화면
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/join")
+ public String join() throws Exception {
+ try {
+ return "anonymous/html/join";
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ return "error/EgovServerError";
+ }
+ }
- if (user == null) {
- model.addAttribute("check", 1);
- } else {
- model.addAttribute("check", 2);
- model.addAttribute("id", user.getUserid());
- }
+ /**
+ * 아이디 중복 체크를 한다.
+ * @param checkId 입력 아이디값
+ * @return 성공, 실패 여부
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/userIdCheck")
+ @ResponseBody
+ public String checkId(@RequestParam("checkId")String checkId) throws Exception {
+ try {
+ int cnt = userService.selectUserIdCheck(checkId);
+ if(cnt > 0) {
+ return "duplicate";
+ }else {
+ return "ok";
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ return "error/EgovServerError";
+ }
+ }
- return "anonymous/findId";
+ /**
+ * 사용자 등록 처리를 한다.
+ * @param userVO 사용자정보 VO
+ * @param model 모델 객체
+ * @return 로그인 화면
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/insertUser")
+ public String userInsert(@ModelAttribute("userVO") UserVO userVO, Model model) throws Exception {
+ try {
+ int result = userService.insertUser(userVO);
+ if(result == 0) {
+ model.addAttribute("url", "/");
+ model.addAttribute("resultMsg", "회원가입이 완료 되었습니다. 승인을 기다려주세요.");
+ return "/redirect";
+ }else {
+ model.addAttribute("resultMsg", "오류가 발생하였습니다.");
+ return null;
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ return "error/EgovServerError";
+ }
+ }
- }
- //pw찾기 페이지 이동
- @RequestMapping(value = "findPwd")
- public String findPwdView(){
- return "anonymous/findPwd";
- }
- //pw찾기 실행
- @RequestMapping(value = "findPwd", method = RequestMethod.POST)
- public String findPwdAction(UserVO userVO, Model model){
- UserVO user = userService.findPwd(userVO);
+ /**
+ * 지역 리스트 가져온다.
+ * @param code 법정동 코드
+ * @param area 지역이름
+ * @return 선택된 지역 리스트
+ * @throws Exception 기본 예외 처리
+ */
+ @RequestMapping(value="/selectAreaList")
+ @ResponseBody
+ public List> selectAreaList(@RequestParam("code")String code, @RequestParam("area")String area) throws Exception {
+ List> countyList = areaCodeService.selectCounty(code, area);
+ return countyList;
+ }
- if (user == null) {
- model.addAttribute("check", 1);
- } else {
- model.addAttribute("check", 0);
- model.addAttribute("updateid", user.getUserid());
- }
- return "anonymous/findPwd";
- }
+ /**
+ * 권한이 없는 사용자가 접근시 권한제한 화면으로 이동한다.
+ *
+ * @return 권한없음 페이지
+ * @exception Exception 기본 예외 처리
+ */
+ @RequestMapping("/error/EgovAccessDenied")
+ public String accessDenied() throws Exception {
+ return "error/EgovAccessDenied";
+ }
+ // 아이디 찾기 페이지 이동
+ @RequestMapping(value = "findId")
+ public String findIdView(){
- //pw 바꾸기 실행
- @RequestMapping(value = "updatepwd", method = RequestMethod.POST)
- public String updatePwdAction(@RequestParam(value = "updateid", defaultValue = "", required = false) String id, UserVO userVO) {
+ return "anonymous/html/findId";
+ }
+ // 아이디 찾기 실행
- userVO.setUserid(id);
- System.out.println(userVO);
- userService.updatePwd(userVO);
- return "anonymous/findPwdConfirm";
- }
+ @RequestMapping(value = "findId", method = RequestMethod.POST)
+ public String findIdAction(UserVO userVO, Model model) {
+ UserVO user = userService.findId(userVO);
- // 비밀번호 변경 성공페이지 이동
- public String CheckPwd(HttpSession session, Model model){
- UserVO loginUser = (UserVO) session.getAttribute("loginUser");
+ if (user == null) {
+ model.addAttribute("check", 1);
+ } else {
+ model.addAttribute("check", 2);
+ model.addAttribute("id", user.getUserid());
+ }
- if (loginUser == null) {
- return "/login";
- } else {
- return "checkform";
- }
- }
+ return "anonymous/html/findId";
+ }
+ //pw찾기 페이지 이동
+ @RequestMapping(value = "findPwd")
+ public String findPwdView(){
+ return "anonymous/html/findPwd";
+ }
+
+ //pw찾기 인증번호 발송
+ @RequestMapping(value = "sendEmail")
+ @ResponseBody
+ public String sendEmail(UserVO user){
+ user = userService.findPwd(user);
+ if(user==null){
+ return "userNull";
+ }else{
+ return userCertificationService.sendCertificationNumber(user);
+ }
+ }
+ //pw찾기 인증번호 확인
+ @RequestMapping(value = "certifyNumCheck")
+ @ResponseBody
+ public String certifyNumCheck(UserCertificationVO certificationVO){
+ UserCertificationVO savedInfo = userCertificationService.selectCertificationInfo(certificationVO);
+ if(savedInfo==null){
+ return "InfoNull";
+ }else if(!savedInfo.getCertification_num().equals(certificationVO.getCertification_num())){
+ return "numberNotMatch";
+ }else if(savedInfo.getStatus().equals("checked")){
+ return "isChecked";
+ }else if(!savedInfo.getExpiration_date().isAfter(LocalDateTime.now())){
+ return "expirationTimeAfter";
+ }else{
+ savedInfo.setStatus("checked");
+ userCertificationService.updateCertificationNumStatus(savedInfo);
+ return "OK";
+ }
+ }
+ //pw찾기 비밀번호 변경
+ @RequestMapping(value = "passwordUpdate", method = RequestMethod.POST)
+ @ResponseBody
+ public String passwordUpdate(UserVO userVO){
+ userService.updatePwd(userVO);
+ return "OK";
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/mca/user/service/UserService.java b/src/main/java/com/mca/user/service/UserService.java
index 93e724d..4e1dbf1 100644
--- a/src/main/java/com/mca/user/service/UserService.java
+++ b/src/main/java/com/mca/user/service/UserService.java
@@ -22,29 +22,22 @@ public class UserService {
}
public int insertUser(UserVO userVO) {
- // TODO Auto-generated method stub
-
try {
/* bcrypt 사용 고려 */
//BCryptPasswordEncoder bcryptPasswordEncoder = new BCryptPasswordEncoder(10);
//userVO.setPassword(bcryptPasswordEncoder.encode(userVO.getPassword()));
-
userMapper.insertUser(userVO);
return 0;
-
}catch (Exception e) {
return -1;
}
-
}
public UserVO selectUserInfo(String userid) {
- // TODO Auto-generated method stub
return userMapper.selectUserInfo(userid);
}
public List> selectUserList(UserSearchVO userSearchVO) {
- // TODO Auto-generated method stub
return userMapper.selectUserList(userSearchVO);
}
diff --git a/src/main/resources/egovframework/sqlmap/mappers/cmmn/UserCertification.xml b/src/main/resources/egovframework/sqlmap/mappers/cmmn/UserCertification.xml
new file mode 100644
index 0000000..742a28b
--- /dev/null
+++ b/src/main/resources/egovframework/sqlmap/mappers/cmmn/UserCertification.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ insert into user_certification values(
+ #{userid}, #{certification_num}, #{expiration_date}, 'ready'
+ )ON DUPLICATE KEY UPDATE
+ certification_num = #{certification_num},
+ expiration_date = #{expiration_date},
+ status = 'ready';
+
+
+
+ update user_certification
+ set status = #{status}
+ where userid = #{userid}
+
+
\ No newline at end of file
diff --git a/src/main/resources/egovframework/sqlmap/mappers/user/user.xml b/src/main/resources/egovframework/sqlmap/mappers/user/user.xml
index e85be7f..4e55d01 100644
--- a/src/main/resources/egovframework/sqlmap/mappers/user/user.xml
+++ b/src/main/resources/egovframework/sqlmap/mappers/user/user.xml
@@ -146,10 +146,13 @@
-
+
update t_user set password=#{password} where userid=#{userid}
\ No newline at end of file
diff --git a/src/main/resources/egovframework/sqlmap/sql-mapper-config.xml b/src/main/resources/egovframework/sqlmap/sql-mapper-config.xml
index 9a3c020..b08e737 100644
--- a/src/main/resources/egovframework/sqlmap/sql-mapper-config.xml
+++ b/src/main/resources/egovframework/sqlmap/sql-mapper-config.xml
@@ -8,6 +8,7 @@
+
diff --git a/src/main/webapp/WEB-INF/jsp/anonymous/findId.jsp b/src/main/webapp/WEB-INF/jsp/anonymous/findId.jsp
index 3da8c1b..5e13b42 100644
--- a/src/main/webapp/WEB-INF/jsp/anonymous/findId.jsp
+++ b/src/main/webapp/WEB-INF/jsp/anonymous/findId.jsp
@@ -3,38 +3,3 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
-
-
diff --git a/src/main/webapp/WEB-INF/jsp/anonymous/findPwd.jsp b/src/main/webapp/WEB-INF/jsp/anonymous/findPwd.jsp
index 38e22b2..048e3a9 100644
--- a/src/main/webapp/WEB-INF/jsp/anonymous/findPwd.jsp
+++ b/src/main/webapp/WEB-INF/jsp/anonymous/findPwd.jsp
@@ -3,64 +3,191 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
-