비밀번호 변경 기능 추가

main
이범준 11 months ago
parent e45792a2d0
commit d8686230e8

@ -36,6 +36,9 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
@Resource(name="userService") @Resource(name="userService")
private UserService userService; private UserService userService;
@Resource(name="user2Bean")
private cokr.xit.fims.base.service.bean.UserBean userBean;
@Resource(name="factionBean") @Resource(name="factionBean")
FactionBean factionBean; FactionBean factionBean;
@ -104,6 +107,16 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
return mav; return mav;
} }
@RequestMapping(name="비밀번호 확인",value="/confirmPassword.do")
public ModelAndView confirmPassword(String password) {
ModelAndView mav = new ModelAndView("jsonView");
boolean result = false;
result = userBean.confirmPassword(password);
mav.addObject("result", result);
return mav;
}
@RequestMapping(name="설정정보 조회",value="/stngInfo.do") @RequestMapping(name="설정정보 조회",value="/stngInfo.do")
public ModelAndView getStngInfo(String type) { public ModelAndView getStngInfo(String type) {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");

@ -0,0 +1,15 @@
package cokr.xit.fims.base.service.bean;
import org.springframework.stereotype.Component;
import cokr.xit.foundation.User;
@Component("user2Bean")
public class UserBean extends cokr.xit.base.user.service.bean.UserBean {
public boolean confirmPassword(String password) {
User user = this.getUser(currentUser().getAccount(), currentUser().getInstitute());
return user.getPassword().equals(passwordEncoder.encode(password));
}
}

@ -34,4 +34,74 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row mt-4 justify-content-end">
<div class="col-md-6">
<div class="row justify-content-end">
<div class="col-sm-3">
<button type="button" onclick="validPassword();" class="btn btn-primary">저장</button>
</div>
</div>
</div>
</div>
</form> </form>
<script>
function validPassword(){
if($("#password-form input[name='currentPassword']").val() == ""){
dialog.alert("현재 비밀번호를 입력하세요.");
return;
}
if($("#password-form input[name='password']").val() == ""){
dialog.alert("새 비밀번호를 입력하세요.");
return;
}
if($("#password-form input[name='confirmPassword']").val() == ""){
dialog.alert("새 비밀번호 확인을 입력하세요.");
return;
}
let match = Array.from(document.querySelectorAll("input[name='password'],input[name='confirmPassword']"))
.map(input => input.value)
.reduce((total, current) => total == current);
if (!match) {
dialog.alert({
content:"새 비밀번호와 새 비밀번호 확인이 다릅니다.",
onClose:function(){
document.querySelector("input[name='confirmPassword']").focus();
}
});
return;
}
ajax.get({
url : wctx.url("/user/confirmPassword.do"),
data : { password : $("#password-form input[name='currentPassword']").val() },
success : (resp) => {
if(resp.result){
savePassword();
} else {
dialog.alert("현재 비밀번호가 일치하지 않습니다.");
}
}
});
}
function savePassword(){
ajax.post({
url : wctx.url("/user/changePassword.do"),
data : {
userID : MY_INFO.id,
password : $("#password-form input[name='password']").val()
},
success : (resp) => {
if(resp.saved){
dialog.alert("비밀번호 변경에 성공하였습니다.");
dialog.close("changePasswordDialog");
} else {
dialog.alert("비밀번호 변경에 실패하였습니다.");
}
}
});
}
</script>
Loading…
Cancel
Save