package nlib.user.web; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import egovframework.com.ext.oauth.service.OAuthUniversalUser; import egovframework.rte.fdl.cryptography.EgovPasswordEncoder; import nlib.restful.service.DataApiReqVO; import nlib.security.SecUserDetailsService; import nlib.security.SecUserVO; import nlib.user.service.LoginService; import nlib.user.service.MemberService; import nlib.user.service.NlibLoginVO; import nlib.user.service.UserInfoService; import nlib.cmm.NlibCommonController; import nlib.cmm.service.NlibProperty; /** *
 * @Class Name : userInfoController.java
 * 
 * @Description : 회원 정보 controller
 * 
 * 
 * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
 *
 * 
* * @ ------------ -------- --------------------------- * @ 수정일 수정자 수정내용 * @ ------------ -------- --------------------------- * @ 2021. 7. 14. JSYOO 최초 생성 * * * @author 이씨플라자 * DIGITALSHIP JSYOO * @since 2021. 7. 14. * @version 1.0 * */ @Controller public class UserInfoController extends NlibCommonController { @Resource(name="userInfoService") private UserInfoService userInfoService; @Resource(name="loginService") private LoginService loginService; @Resource(name = "egovEnvPasswordEncoderService") EgovPasswordEncoder egovPasswordEncoder; @Resource(name = "userDetailsService") private SecUserDetailsService SecUserDetailsService; /** * 내 정보 조회 * @exception Exception */ @RequestMapping(value="/userInfo/getMyInfo.do") public String getMyInfo(HttpServletResponse response,HttpServletRequest request) throws Exception{ return "nlib/userInfo/getMyInfo"; } /** * 내 정보 수정 페이지 * @exception Exception */ @RequestMapping(value="/userInfo/putMyInfo.do") public String putMyInfo(NlibLoginVO vo,HttpServletResponse response,HttpServletRequest request,Authentication authentication,ModelMap model) throws Exception{ //사용자 정보를 가져온다. NlibLoginVO loginVO = getNlibLoginVO(authentication); loginVO.setJoinCouncilCd(getCurCouncilCd(request)); loginVO = loginService.selectLoginUserInfo(loginVO); List snsList = new ArrayList(); //sns연동 계정 리스트 snsList = userInfoService.selectSnsSignUpList(loginVO); String encodedText=null; System.out.println(loginVO.getLoginUserId()+vo.getPassword()); encodedText = egovPasswordEncoder.encryptPassword(loginVO.getLoginUserId()+vo.getPassword()); vo.setPassword(encodedText); //암호화된 패스워드 비교 if(loginVO.getPassword().equals(vo.getPassword())) { model.addAttribute("loginVO",loginVO); model.addAttribute("snsList",snsList); return "nlib/userInfo/putMyInfo"; }else { model.addAttribute("msg","비밀번호가 일치하지않습니다."); model.addAttribute("url","/nlib/userInfo/pwCertMyInfo.do"); return "nlib/cmm/alert"; } } /** * 내 정보 수정 * @return * @exception Exception */ @RequestMapping(value="/userInfo/updateMyInfo.do" , method=RequestMethod.POST) public String updateMyInfo(NlibLoginVO vo,Authentication authentication,HttpServletResponse response,HttpServletRequest request,ModelMap model) throws Exception{ //사용자 정보를 가져온다. NlibLoginVO loginVO = getNlibLoginVO(authentication); //이메일인증 확인 if(!(vo.getEmail().equals(loginVO.getEmail()))) { if(!(vo.getEmailVrfctNo().equals(loginVO.getEmailVrfctNo())) ||loginVO.getEmailVrfctDd() == null) { model.addAttribute("msg","이메일인증이 정상적이지않습니다."); model.addAttribute("url","${pageContext.request.contextPath}"+"/userInfo/getMyInfo.do"); return "nlib/cmm/alert"; } vo.setEmail(loginVO.getEmailTemp()); } //핸드폰인증 확인 if(!(vo.getMobileNo().equals(loginVO.getMobileNo()))) { if(!(vo.getMobileVrfctNo().equals(loginVO.getMobileVrfctNo())) ||loginVO.getMobileVrfctDd() == null) { model.addAttribute("msg","핸드폰인증이 정상적이지않습니다."); model.addAttribute("url","${pageContext.request.contextPath}"+"/userInfo/getMyInfo.do"); return "nlib/cmm/alert"; } vo.setMobileNo(loginVO.getMobileTemp()); } String encodedText=null; encodedText = egovPasswordEncoder.encryptPassword(vo.getPassword()); vo.setPassword(encodedText); // 내 정보 수정 userInfoService.updateMyInfo(vo); NlibLoginVO sessionVO=(NlibLoginVO) SecUserDetailsService.loadUserByUsername(vo.getLoginUserId()); //세션에 수정정보로 재 주입 replaceNlibLoginVO(request,sessionVO); return "nlib/userInfo/getMyInfo"; } /** * 내 정보 수정 전 password 인증 * @exception Exception */ @RequestMapping(value="/userInfo/pwCertMyInfo.do") public String pwCertMyInfo(HttpServletResponse response,HttpServletRequest request) throws Exception{ return "nlib/userInfo/pwCertMyInfo"; } /** SNS연동을 해지한다. * @param response * @param request * @return * @return * @throws Exception */ @RequestMapping(value="/userInfo/deleteSnsLink.ajax") public @ResponseBody void deleteSnsLink(HttpServletResponse response,HttpServletRequest request) throws Exception{ OAuthUniversalUser oAuthVO = new OAuthUniversalUser(); oAuthVO.setMbSnsId(request.getParameter("mbSnsId")); userInfoService.deleteSnsLink(oAuthVO); } }