Examples of UnifiedUser


Examples of com.jeecms.core.entity.UnifiedUser

  public Authentication login(String username, String password, String ip,
      HttpServletRequest request, HttpServletResponse response,
      SessionProvider session) throws UsernameNotFoundException,
      BadCredentialsException {
    UnifiedUser user = unifiedUserMng.login(username, password, ip);
    Authentication auth = new Authentication();
    auth.setUid(user.getId());
    auth.setUsername(user.getUsername());
    auth.setEmail(user.getEmail());
    auth.setLoginIp(ip);
    save(auth);
    session.setAttribute(request, response, AUTH_KEY, auth.getId());
    return auth;
  }
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

@Service
@Transactional
public class UnifiedUserMngImpl implements UnifiedUserMng {
  public UnifiedUser passwordForgotten(Integer userId, EmailSender email,
      MessageTemplate tpl) {
    UnifiedUser user = findById(userId);
    String uuid = StringUtils.remove(UUID.randomUUID().toString(), '-');
    user.setResetKey(uuid);
    String resetPwd = RandomStringUtils.randomNumeric(10);
    user.setResetPwd(resetPwd);
    senderEmail(user.getId(), user.getUsername(), user.getEmail(), user
        .getResetKey(), user.getResetPwd(), email, tpl);
    return user;
  }
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

        .getRegisterSubject(), text, email.getPersonal(), "", "");
    sendEmail.send();
  }

  public UnifiedUser resetPassword(Integer userId) {
    UnifiedUser user = findById(userId);
    user.setPassword(pwdEncoder.encodePassword(user.getResetPwd()));
    user.setResetKey(null);
    user.setResetPwd(null);
    return user;
  }
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

  public Integer errorRemaining(String username) {
    if (StringUtils.isBlank(username)) {
      return null;
    }
    UnifiedUser user = getByUsername(username);
    if (user == null) {
      return null;
    }
    long now = System.currentTimeMillis();
    ConfigLogin configLogin = configMng.getConfigLogin();
    int maxErrorTimes = configLogin.getErrorTimes();
    int maxErrorInterval = configLogin.getErrorInterval() * 60 * 1000;
    Integer errorCount = user.getErrorCount();
    Date errorTime = user.getErrorTime();
    if (errorCount <= 0 || errorTime == null
        || errorTime.getTime() + maxErrorInterval < now) {
      return maxErrorTimes;
    }
    return maxErrorTimes - errorCount;
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    return maxErrorTimes - errorCount;
  }

  public UnifiedUser login(String username, String password, String ip)
      throws UsernameNotFoundException, BadCredentialsException {
    UnifiedUser user = getByUsername(username);
    if (user == null) {
      throw new UsernameNotFoundException("username not found: "
          + username);
    }
    System.out.println("com.jeecms.core.manager.impl.UnifiedUserMngImpl.login 这里我把密码取消了");
    /*
    if (!pwdEncoder.isPasswordValid(user.getPassword(), password)) {
      updateLoginError(user.getId(), ip);
      throw new BadCredentialsException("password invalid");
    }
    if (!user.getActivation()) {
      throw new BadCredentialsException("account not activated");
    }
    */
    updateLoginSuccess(user.getId(), ip);
    return user;
  }
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    updateLoginSuccess(user.getId(), ip);
    return user;
  }

  public void updateLoginSuccess(Integer userId, String ip) {
    UnifiedUser user = findById(userId);
    Date now = new Timestamp(System.currentTimeMillis());

    user.setLoginCount(user.getLoginCount() + 1);
    user.setLastLoginIp(ip);
    user.setLastLoginTime(now);

    user.setErrorCount(0);
    user.setErrorTime(null);
    user.setErrorIp(null);
  }
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    WebErrors errors = validateForgotPasswordSubmit(username, email,
        captcha, request, response);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    UnifiedUser user = unifiedUserMng.getByUsername(username);
    EmailSender sender = configMng.getEmailSender();
    MessageTemplate msgTpl = configMng.getForgotPasswordMessageTemplate();
    model.addAttribute("user", user);
    FrontUtils.frontData(request, model, site);
    if (user == null) {
      // 用户名不存在
      model.addAttribute("status", 1);
    } else if (StringUtils.isBlank(user.getEmail())) {
      // 用户没有设置邮箱
      model.addAttribute("status", 2);
    } else if (!user.getEmail().equals(email)) {
      // 邮箱输入错误
      model.addAttribute("status", 3);
    } else if (sender == null) {
      // 邮件服务器没有设置好
      model.addAttribute("status", 4);
    } else if (msgTpl == null) {
      // 邮件模板没有设置好
      model.addAttribute("status", 5);
    } else {
      try {
        unifiedUserMng.passwordForgotten(user.getId(), sender, msgTpl);
        model.addAttribute("status", 0);
      } catch (Exception e) {
        // 发送邮件异常
        model.addAttribute("status", 100);
        model.addAttribute("message", e.getMessage());
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    CmsSite site = CmsUtils.getSite(request);
    WebErrors errors = validatePasswordReset(uid, key, request);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    UnifiedUser user = unifiedUserMng.findById(uid);
    if (user == null) {
      // 用户不存在
      model.addAttribute("status", 1);
    } else if (StringUtils.isBlank(user.getResetKey())) {
      // resetKey不存在
      model.addAttribute("status", 2);
    } else if (!user.getResetKey().equals(key)) {
      // 重置key错误
      model.addAttribute("status", 3);
    } else {
      unifiedUserMng.resetPassword(uid);
      model.addAttribute("status", 0);
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    CmsSite site = CmsUtils.getSite(request);
    WebErrors errors = validateActive(username, key, request, response);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    UnifiedUser user = unifiedUserMng.active(username, key);
    String ip = RequestUtils.getIpAddr(request);
    authMng.activeLogin(user, ip, request, response, session);
    FrontUtils.frontData(request, model, site);
    return FrontUtils.getTplPath(request, site.getSolutionPath(),
        TPLDIR_MEMBER, REGISTER_ACTIVE_SUCCESS);
View Full Code Here

Examples of com.jeecms.core.entity.UnifiedUser

    if (StringUtils.isBlank(username)
        || StringUtils.isBlank(activationCode)) {
      errors.addErrorCode("error.exceptionParams");
      return errors;
    }
    UnifiedUser user = unifiedUserMng.getByUsername(username);
    if (user == null) {
      errors.addErrorCode("error.usernameNotExist");
      return errors;
    }
    if (user.getActivation()
        || StringUtils.isBlank(user.getActivationCode())) {
      errors.addErrorCode("error.usernameActivated");
      return errors;
    }
    if (!user.getActivationCode().equals(activationCode)) {
      errors.addErrorCode("error.exceptionActivationCode");
      return errors;
    }
    return errors;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.