@RequestMapping(value = "/adminreset", method = RequestMethod.POST) public ModelAndView adminReset(HttpServletRequest request, @RequestParam("id") String adminId) { System.out.println("In auth adminresetForm method"); String autopwd = request.getParameter("autopwd"); System.out.println("autopwd" + autopwd); String newpassword = request.getParameter("newpassword"); System.out.println("newpassword" + newpassword); String adminid = request.getParameter("adminid"); System.out.println("adminid" + adminid); ModelAndView model = new ModelAndView(); Admin admin = new Admin(); System.out.println("adminId" + adminId); merchantService.updateadminreset(adminId, newpassword); List<Admin> merchantdetails = merchantService.admindetails(adminId); System.out.println("merchantdetails==>" + merchantdetails); System.out.println("merchantdetails" + merchantdetails); String adminuname = merchantdetails.get(0).getUsername(); System.out.println("adminuname" + adminuname); String adminautopassword = merchantdetails.get(0).getAutopassword(); System.out.println("adminautopassword" + adminautopassword); String adminnewpassword = merchantdetails.get(0).getPassword(); System.out.println("adminnewpassword" + adminnewpassword); if (autopwd.equals(adminautopassword) && newpassword.equals(adminnewpassword)) { System.out.println("success"); model.setViewName("/acquirer/adminlogin"); } else { String error = "Enter the correct autopassword and newpassword"; System.out.println("error" + error); model = new ModelAndView("/acquirer/adminresetpassword"); model.addObject("error", error); } return model; }
@RequestMapping(value = "/adminchange", method = RequestMethod.POST) public ModelAndView adminChange(HttpServletRequest request) { System.out.println("In auth adminChange method"); String newpassword = request.getParameter("newpassword"); System.out.println("newpassword" + newpassword); ModelAndView model = new ModelAndView(); try { Admin admin = new Admin(); HttpSession sessionObj = request.getSession(); String adminid = sessionObj.getAttribute("adminid").toString(); // sessionObj.setAttribute("adminname" , adminname); System.out.println("adminid" + adminid); List<Admin> merchantdetails = merchantService.admindetails(adminid); System.out.println("merchantdetails==>" + merchantdetails); String adminpwd = merchantdetails.get(0).getPassword(); System.out.println("adminpwd" + adminpwd); String adminpwd1 = merchantdetails.get(0).getPasswd1(); System.out.println("adminpwd1" + adminpwd1); if (adminpwd1 == null && !adminpwd.equals(newpassword)) { merchantService.updatepwd1(adminid, newpassword); } else { model.setViewName("acquirer/changepwdpopup"); String adminpwd2 = merchantdetails.get(0).getPasswd2(); System.out.println("adminpwd2" + adminpwd2); if (adminpwd2 == null && !adminpwd.equals(newpassword) && !adminpwd1.equals(newpassword)) { merchantService.updatepwd2(adminid, newpassword); } else { model.setViewName("acquirer/changepwdpopup"); if (!adminpwd2.equals(newpassword) && !adminpwd.equals(newpassword) && !adminpwd1.equals(newpassword)) { merchantService.updateadminreset(adminid, adminpwd1); System.out.println("updateadminreset"); merchantService.updatepwd1(adminid, adminpwd2); System.out.println("updatepwd1"); merchantService.updatepwd2(adminid, newpassword); System.out.println("updatepwd2"); String note = "Reset password Successfully"; System.out.println("note" + note); model.addObject("note", note); model.setViewName("acquirer/changepwdpopup"); model.addObject("pagename", "resetsuccess"); // model.setViewName("/acquirer/adminlogin"); } else { String note1 = "You are not allowed to enter last three Password"; System.out.println("note" + note1); model.addObject("error", note1); model.setViewName("acquirer/changepwdpopup"); // merchantService.updateadminreset(adminid,newpassword); } } } } catch (Exception e) { e.printStackTrace(); } return model; }