Ejemplo n.º 1
0
  @ResponseBody
  @RequestMapping("/updatePassword")
  public String updatePassword(Model model, User user, String newPassword) {
    if (StringUtils.isBlank(newPassword)) {
      return format(JSON_MSG, 1, "password cann't empty !");
    }

    boolean success =
        userService.updateUserPassword(user.getUsername(), generatePassword(newPassword.trim()));
    if (success) {
      return format(JSON_MSG, 1, "update " + user.getUsername() + "'s password success !");
    } else {
      return format(JSON_MSG, 0, "update " + user.getUsername() + "'s password faild !");
    }
  }
Ejemplo n.º 2
0
 @NeedLogin(false)
 @RequestMapping("/login")
 public String login(
     String username,
     String password,
     String type,
     HttpSession session,
     RedirectAttributes redirectAttrs) {
   session.setAttribute(
       "user", userService.findByUsernameAndPassword(username, generatePassword(password)));
   if ("toProductCode".equals(type)) {
     redirectAttrs.addFlashAttribute("username", username).addFlashAttribute("password", password);
     return "redirect:/trade/listpcode.do";
   }
   return "index";
 }