Skip to content

Commit

Permalink
chore: enforce username format rules in additional places (#15703) (#…
Browse files Browse the repository at this point in the history
…16169)

* chore: enforce username format rules in additional places (#15703)
  • Loading branch information
netroms authored Jan 16, 2024
1 parent d75fbe7 commit d372db8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import org.hisp.dhis.schema.descriptors.UserSchemaDescriptor;
import org.hisp.dhis.security.RestoreOptions;
import org.hisp.dhis.security.SecurityService;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.user.CredentialsInfo;
import org.hisp.dhis.user.CurrentUser;
import org.hisp.dhis.user.PasswordValidationResult;
Expand Down Expand Up @@ -450,6 +451,10 @@ public WebMessage replicateUser(
return conflict("Username must be specified");
}

if (!ValidationUtils.usernameIsValid(username, false)) {
return conflict("Username is not valid");
}

if (userService.getUserByUsername(username) != null) {
return conflict("Username already taken: " + username);
}
Expand Down

0 comments on commit d372db8

Please sign in to comment.