/**
   * 验证用户
   *
   * @param request
   * @param response
   * @param model
   * @return
   */
  @RequestMapping("/checkLogin.do")
  public String checkLogin(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam("userName") String userName,
      @RequestParam("passWord") String passWord,
      Model model) {
    logger.debug("logon request: {username={}, password={}}", userName, passWord);
    boolean checkPassword = identityService.checkPassword(userName, passWord);

    HttpSession session = request.getSession(true);

    if (checkPassword) {
      User user = identityService.createUserQuery().userId(userName).singleResult();
      session.setAttribute("user", user);
      GroupQuery groupQuery = identityService.createGroupQuery();
      List<Group> groupList = groupQuery.groupMember(userName).list();

      session.setAttribute("groups", groupList);

      String[] groupNames = new String[groupList.size()];

      for (int i = 0; i < groupNames.length; i++) {
        groupNames[i] = groupList.get(i).getName();
      }

      session.setAttribute("groupNames", ArrayUtils.toString(groupNames));
      return "redirect:/simple/index.do";
    } else {
      return "redirect:/simple/login.do";
    }
  }
Пример #2
0
 public String findByPage() {
   Page<Group> page = new Page<Group>(PageUtil.PAGE_SIZE);
   int[] params = PageUtil.init(page, request);
   GroupQuery query = identifyService.createGroupQuery().orderByGroupId().asc();
   List<Group> result = query.listPage(params[0], params[1]);
   page.setTotalCount(query.count());
   page.setResult(result);
   request.setAttribute("page", page);
   return "groupList";
 }