Skip to content

Commit

Permalink
allow hyphen in username (#731)
Browse files Browse the repository at this point in the history
* allow hyphen in username

* remove extra escaping

---------

Co-authored-by: Enrice <[email protected]>
  • Loading branch information
Enrice and Enrice authored Nov 3, 2023
1 parent 13762eb commit 428e898
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ValidationUtil {

private static Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9_]+");

private static Pattern USERNAME_PATTERN = Pattern.compile("[a-zA-Z0-9_@\\.]+");
private static Pattern USERNAME_PATTERN = Pattern.compile("[a-zA-Z0-9_@.-]+");

/**
* Checks that the argument is not null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public Response addMember(@PathParam("groupName") String groupName,
* @return Response
*/
@DELETE
@Path("{groupName: [a-zA-Z0-9_]+}/{username: [a-zA-Z0-9_@\\.]+}")
@Path("{groupName: [a-zA-Z0-9_]+}/{username: [a-zA-Z0-9_@.-]+}")
public Response removeMember(@PathParam("groupName") String groupName,
@PathParam("username") String username) {
if (!authenticate()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public Response update(
* @return Response
*/
@POST
@Path("{username: [a-zA-Z0-9_@\\.]+}")
@Path("{username: [a-zA-Z0-9_@.-]+}")
public Response update(
@PathParam("username") String username,
@FormParam("password") String password,
Expand Down Expand Up @@ -497,7 +497,7 @@ public Response delete() {
* @return Response
*/
@DELETE
@Path("{username: [a-zA-Z0-9_@\\.]+}")
@Path("{username: [a-zA-Z0-9_@.-]+}")
public Response delete(@PathParam("username") String username) {
if (!authenticate()) {
throw new ForbiddenClientException();
Expand Down Expand Up @@ -563,7 +563,7 @@ public Response delete(@PathParam("username") String username) {
* @return Response
*/
@POST
@Path("{username: [a-zA-Z0-9_@\\.]+}/disable_totp")
@Path("{username: [a-zA-Z0-9_@.-]+}/disable_totp")
public Response disableTotpUsername(@PathParam("username") String username) {
if (!authenticate()) {
throw new ForbiddenClientException();
Expand Down Expand Up @@ -685,7 +685,7 @@ public Response info() {
* @return Response
*/
@GET
@Path("{username: [a-zA-Z0-9_@\\.]+}")
@Path("{username: [a-zA-Z0-9_@.-]+}")
@Produces(MediaType.APPLICATION_JSON)
public Response view(@PathParam("username") String username) {
if (!authenticate()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h2 ng-show="!isEdit()" translate="settings.user.edit.add_user_title"></h2>
<label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label>
<div class="col-sm-7">
<input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control"
ng-pattern="/^[a-zA-Z0-9_@\.]*$/"
ng-pattern="/^[a-zA-Z0-9_@.-]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/>
</div>

Expand Down

0 comments on commit 428e898

Please sign in to comment.