Esempio n. 1
0
  // 登陆
  public String login() {
    // 先从session中取empModel
    EmpModel loginEmp = null;
    loginEmp = getLogin();
    if (loginEmp == null) {
      // 添加登陆ip(lastLoginIp)
      HttpServletRequest request = ServletActionContext.getRequest();
      String loginIp = request.getHeader("x-forwarded-for");
      if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
        loginIp = request.getHeader("Proxy-Client-IP");
      }
      if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
        loginIp = request.getHeader("WL-Proxy-Client-IP");
      }
      if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) {
        loginIp = request.getRemoteAddr();
      }
      // 根据业务层查询登陆的用户,用户名/密码是否正确
      loginEmp = empEbi.login(emp.getUserName(), emp.getPwd(), loginIp);
    }
    // 判断是否查到用户
    if (loginEmp != null) {
      // 将用户信息放入session中

      putSession(EmpModel.LOGIN_EMP_INFO, loginEmp);
      return "loginSuccess";
    } else {
      // 添加错误提示信息
      this.addActionError("用户名/密码错误!");
      return "loginFail";
    }
  }
Esempio n. 2
0
 public String changePwd() {
   //
   // 从session中获取emp
   EmpModel em = (EmpModel) get(EmpModel.LOGIN_EMP_INFO);
   put(EmpModel.LOGIN_EMP_INFO, null);
   empEbi.changePwd(em.getUserName(), em.getPwd(), newPwd);
   return "loginFail";
 }