@RequestMapping(value = "/index.do", method = RequestMethod.POST) public String getIndexPage( @RequestParam(value = "error", required = false) boolean error, ModelMap model, HttpServletRequest request, RedirectAttributes redirectAttributes) { logger.debug("Received request to show Index page POST"); if (rpHash(request.getParameter("defaultReal")) .equals(request.getParameter("defaultRealHash"))) { // if enter here means valid // here we generate OTP String sOTP = com.mobipay.customerkycweb.util.Utils.generateOTP(); String sMDN = request.getParameter("mdn"); if (sMDN.startsWith("0")) sMDN = sMDN.substring(1, sMDN.length()); String sCountryCode = request.getParameter("countrycode"); sMDN = sCountryCode + sMDN; System.out.println(">>>>>> " + sMDN + "<<<<<<<"); User user = new User(); user.setMdn(sMDN); user.setOtp(sOTP); // check if MDN already in registered as customer List<Customer> listCust = custService.searchByName(sMDN); if (listCust.size() < 1) { model.addAttribute("errors", "You are not registered as User!"); model.addAttribute("countryCodeList", CommonCollection.getCountryCode()); return "index"; } else { // check if user exist > create new user in DB if not exist List<User> listUser = userService.searchByMDN(sMDN); if (listUser.size() < 1) { user.setPassword(new EncryptSHA().Encrypt(sOTP)); user.setRoleid(1); user.setStatus("1"); user.setLastupdate(dateFormat.format(date)); userService.updateOrSaveUser(user); } else { // save newest OTP become password userService.customUpdateUser(user); } // send OTP to customer String sResult = com.mobipay.customerkycweb.util.Utils.sendOTP(sMDN, sOTP, otp_link); System.out.println("%%%%%%>>> " + sOTP + " " + sResult); redirectAttributes.addFlashAttribute("mdn", sMDN); return "redirect:login.do"; } } else { model.addAttribute("errors", "Please Enter Correct Captcha!!"); model.addAttribute("countryCodeList", CommonCollection.getCountryCode()); return "index"; } }
@RequestMapping(value = "/index.do", method = RequestMethod.GET) public String getIndex2Page( @RequestParam(value = "defaultReal", required = false) boolean error, ModelMap modelMap) { logger.debug("Received request to show Index page"); modelMap.addAttribute("countryCodeList", CommonCollection.getCountryCode()); return "index"; }