Package com.lanyuan.entity

Examples of com.lanyuan.entity.User


          "用户名或密码不能为空!");// 在界面输出自定义的信息!!
      throw exception;
    }

    // 验证用户账号与密码是否正确
    User users = this.userDao.querySingleUser(username);
    if (users == null || !users.getUserPassword().equals(password)) {
      BadCredentialsException exception = new BadCredentialsException(
          "用户名或密码不匹配!");// 在界面输出自定义的信息!!
      // request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION,
      // exception);
      throw exception;
    }
    // 当验证都通过后,把用户信息放在session里
    request.getSession().setAttribute("userSession", users);
    // 记录登录信息
    UserLoginList userLoginList = new UserLoginList();
    userLoginList.setUserId(users.getUserId());
    System.out.println("userId----" + users.getUserId() + "---ip--"
        + Common.toIpAddr(request));
    userLoginList.setLoginIp(Common.toIpAddr(request));
    userLoginListService.add(userLoginList);
    // 实现 Authentication
    UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
View Full Code Here


   * @param videoTypeIds
   * @return
   */
  @RequestMapping("getById")
  public String getById(Model model, String userId, int type) {
    User user = userService.getById(userId);
    model.addAttribute("user", user);
     List<Roles> roles=rolesService.findAll();
     model.addAttribute("roles", roles);
    if (type == 1) {
      return "/background/user/edit";
View Full Code Here

   * 给用户分配角色界面
   * @return
   */
  @RequestMapping("userRole")
  public String userRole(Model model,String userId){
    User user = userService.getById(userId);
    model.addAttribute("user", user);
    List<Roles> roles = rolesService.findAll();
    model.addAttribute("roles", roles);
    return "/background/user/userRole";
  }
View Full Code Here

      if (Common.isEmpty(username) || Common.isEmpty(password)) {
        request.setAttribute("error","用户名或密码不能为空!");
        return "/background/framework/login";
      }
      // 验证用户账号与密码是否正确
      User users = this.userDao.querySingleUser(username);
      if (users == null || !users.getUserPassword().equals(password)) {
        request.setAttribute("error", "用户或密码不正确!");
          return "/background/framework/login";
      }
      Authentication authentication = myAuthenticationManager
          .authenticate(new UsernamePasswordAuthenticationToken(username,password));
      SecurityContext securityContext = SecurityContextHolder.getContext();
      securityContext.setAuthentication(authentication);
      HttpSession session = request.getSession(true)
        session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext)
        // 当验证都通过后,把用户信息放在session里
      request.getSession().setAttribute("userSession", users);
      // 记录登录信息
      UserLoginList userLoginList = new UserLoginList();
      userLoginList.setUserId(users.getUserId());
      userLoginList.setLoginIp(Common.toIpAddr(request));
      userLoginListService.add(userLoginList);
    } catch (AuthenticationException ae) { 
      request.setAttribute("error", "登录异常,请联系管理员!");
        return "/background/framework/login";
View Full Code Here

TOP

Related Classes of com.lanyuan.entity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.