Exemplo n.º 1
0
 private WebErrors validateActive(
     String username,
     String activationCode,
     HttpServletRequest request,
     HttpServletResponse response) {
   WebErrors errors = WebErrors.create(request);
   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;
 }
Exemplo n.º 2
0
 private WebErrors validateSubmit(
     String username,
     String email,
     String password,
     String captcha,
     CmsSite site,
     HttpServletRequest request,
     HttpServletResponse response) {
   WebErrors errors = WebErrors.create(request);
   try {
     if (!imageCaptchaService.validateResponseForID(
         session.getSessionId(request, response), captcha)) {
       errors.addErrorCode("error.invalidCaptcha");
       return errors;
     }
   } catch (CaptchaServiceException e) {
     errors.addErrorCode("error.exceptionCaptcha");
     log.warn("", e);
     return errors;
   }
   if (errors.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     errors.addErrorCode("error.usernameExist");
     return errors;
   }
   return errors;
 }