Пример #1
0
 /**
  * Save a new lead or return true if existing.
  *
  * @param principal
  */
 public boolean saveLead(String principal) {
   Identity identity = identityRepository.findByPrincipal(principal);
   List<Lead> leads = leadRepository.findByPrincipal(principal);
   if (identity == null && (leads == null || leads.size() == 0)) {
     leadRepository.save(new Lead(principal, new Date()));
     return false;
   }
   return true;
 }
Пример #2
0
  /**
   * Save the signup form.
   *
   * @param signup
   * @param ipAddress
   */
  public Signup saveSignup(Signup signup, String ipAddress) {
    Identity identity = identityRepository.findByPrincipal(signup.getPrincipal());

    if (identity == null) {
      identity = identityRepository.saveAndFlush(signup.createIdentityFromForm());
      logger.info("New identity {} created", identity.getPrincipal());
    }
    // TODO save the ipAddress
    return signupRepository.saveAndFlush(signup);
  }
Пример #3
0
  /**
   * Verify if email exists
   *
   * @param signup
   */
  public boolean searchPrincipal(Signup signup) {
    List<User> userList = userRepository.findByIdentityPrincipal(signup.getPrincipal());
    Identity identity = identityRepository.findByPrincipal(signup.getPrincipal());

    if (identity == null
        && userList.size() == 0) { // se o email não exisite, pode inseri-lom entao retorna true
      return true;
    }
    return false;
  }
Пример #4
0
 /**
  * True if all existing users for the identity are valid, otherwise admin is notified, except if
  * principal is empty.
  *
  * @param contextId
  * @param principal
  */
 public boolean notifyAdminIfUserIsNotValid(Integer contextId, String principal) {
   if (principal != null && principal.length() > 0) {
     Identity identity = identityRepository.findByPrincipal(principal);
     Signup signup = new Signup(contextId, principal);
     if (identity != null) {
       signup.setFirstName(identity.getIdentityFirstName());
     }
     return allUsersForIdentityAreValid(signup);
   }
   return false;
 }