Skip to content

Commit

Permalink
Allow dots in user and group names (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Jan 9, 2025
1 parent b504a76 commit f5799d8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions mwdb/schema/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class GroupNameSchemaBase(Schema):

@validates("name")
def validate_name(self, name):
if not re.match("^[A-Za-z0-9_-]{1,32}$", name):
if not re.match("^[A-Za-z0-9_.-]{1,32}$", name):
raise ValidationError(
"Group should contain max 32 chars and include only "
"letters, digits, underscores and dashes"
"letters, digits, underscores, dots and dashes"
)
if name.lower() == "private":
raise ValidationError("Group cannot be named private")
Expand All @@ -29,10 +29,10 @@ class GroupUpdateRequestSchema(Schema):

@validates("name")
def validate_name(self, name):
if name is not None and not re.match("^[A-Za-z0-9_-]{1,32}$", name):
if name is not None and not re.match("^[A-Za-z0-9_.-]{1,32}$", name):
raise ValidationError(
"Group should contain max 32 chars and include only "
"letters, digits, underscores and dashes"
"letters, digits, underscores, dots and dashes"
)


Expand Down
4 changes: 2 additions & 2 deletions mwdb/schema/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class ShareRequestSchema(Schema):

@validates("group")
def validate_name(self, name):
if not re.match("^[A-Za-z0-9_-]{1,32}$", name):
if not re.match("^[A-Za-z0-9_.-]{1,32}$", name):
raise ValidationError(
"Group should contain max 32 chars and include only "
"letters, digits, underscores and dashes"
"letters, digits, underscores, dots and dashes"
)


Expand Down
4 changes: 2 additions & 2 deletions mwdb/schema/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class UserLoginSchemaBase(Schema):

@validates("login")
def validate_login(self, value):
if not re.match("^[A-Za-z0-9_-]{1,32}$", value):
if not re.match("^[A-Za-z0-9_.-]{1,32}$", value):
raise ValidationError(
"Login should contain max 32 chars and include only "
"letters, digits, underscores and dashes"
"letters, digits, underscores, dots and dashes"
)
if value.lower() == "private":
raise ValidationError("User cannot be named private")
Expand Down
4 changes: 2 additions & 2 deletions mwdb/web/src/components/Settings/Views/GroupCreateView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type FormValues = {
const validationSchema: Yup.SchemaOf<FormValues> = Yup.object().shape({
name: Yup.string()
.matches(
/[A-Za-z0-9_-]/,
"Group name must contain only letters, digits, '_' and '-' characters"
/[A-Za-z0-9_.-]/,
"Group name must contain only letters, digits, '_', '.' and '-' characters"
)
.max(32, "Max 32 characters allowed.")
.required("Name is required"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function GroupDetailsView() {
defaultValue={group.name!}
onSubmit={handleUpdate}
required
pattern="[A-Za-z0-9_-]{1,32}"
pattern="[A-Za-z0-9_.-]{1,32}"
/>
</DetailsRecord>
<DetailsRecord label="Members">
Expand Down
4 changes: 2 additions & 2 deletions mwdb/web/src/components/Settings/Views/UserCreateView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type FormValues = CreateUser;
const validationSchema: Yup.SchemaOf<FormValues> = Yup.object().shape({
login: Yup.string()
.matches(
/[A-Za-z0-9_-]/,
"Login must contain only letters, digits, '_' and '-'"
/[A-Za-z0-9_.-]/,
"Login must contain only letters, digits, '_', '.' and '-'"
)
.max(32, "Max 32 characters allowed.")
.required("Login is required"),
Expand Down
4 changes: 2 additions & 2 deletions mwdb/web/src/components/Views/UserRegisterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const validationSchema: Yup.SchemaOf<FormValues> = Yup.object().shape({
login: Yup.string()
.required("Login is required")
.matches(
/[A-Za-z0-9_-]{1,32}/,
"Login must contain only letters, digits, '_'and '-' characters, max 32 characters allowed."
/[A-Za-z0-9_.-]{1,32}/,
"Login must contain only letters, digits, '_', '.' and '-' characters, max 32 characters allowed."
),
email: Yup.string()
.required("Email is required")
Expand Down

0 comments on commit f5799d8

Please sign in to comment.