Skip to content

Commit

Permalink
Merge pull request flowable#6 from VeridianDynamics/inuits-6.4.0
Browse files Browse the repository at this point in the history
Check user ID for duplicates before attempting user creation
  • Loading branch information
VeridianDynamics committed Apr 16, 2019
2 parents 5c9a439 + d4e89e7 commit 3dc02c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ flowableApp.controller('IdmCreateUserPopupController', ['$rootScope', '$scope',
if (status == 403) {
$scope.model.errorMessage = "Forbidden";
} else if (status == 409) {
$scope.model.errorMessage = "A user with that email address already exists";
$scope.model.errorMessage = "A user with that ID or email address already exists";
} else {
$scope.$hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.flowable.ui.common.service.exception.ConflictingRequestException;
import org.flowable.ui.common.service.exception.NotFoundException;
import org.flowable.ui.idm.model.UserInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -35,6 +37,8 @@
@Service
@Transactional
public class UserServiceImpl extends AbstractIdmService implements UserService {

private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

private static final int MAX_USER_SIZE = 100;

Expand Down Expand Up @@ -121,7 +125,13 @@ public User createNewUser(String id, String firstName, String lastName, String e
throw new BadRequestException("Id, password and first name are required");
}

if (email != null && identityService.createUserQuery().userEmail(email).count() > 0) {
if (StringUtils.isNotBlank(email) && identityService.createUserQuery().userEmail(email).count() > 0) {
LOGGER.error("INUITS FIX: User with email '{}' already exists", email);
throw new ConflictingRequestException("User already registered", "ACCOUNT.SIGNUP.ERROR.ALREADY-REGISTERED");
}

if (identityService.createUserQuery().userId(id).count() > 0) {
LOGGER.error("INUITS FIX: User with id '{}' already exists", id);
throw new ConflictingRequestException("User already registered", "ACCOUNT.SIGNUP.ERROR.ALREADY-REGISTERED");
}

Expand Down

0 comments on commit 3dc02c8

Please sign in to comment.