@Override
  public void validate(Object auth, Errors errors) {
    User user = (User) auth;

    List<User> users = userService.getUsersByEmail(user.getEmail());

    if (users.size() > 0) {
      errors.rejectValue("email", "user.email.suchEmailAlreadyExists");
    }
  }
Exemplo n.º 2
0
  @Override
  public void validate(Object auth, Errors errors) {
    User fUser = (User) auth;
    User pUser;

    try {
      pUser = userService.getUserByUsername(fUser.getUsername());
    } catch (UsernameNotFoundException notFoundException) {
      pUser = null;
    }

    if (pUser != null) {
      errors.rejectValue("username", "user.username.suchLoginAlreadyExists");
    }
  }