Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dots in user and group names #1014

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading