From f5799d8fac44628f4120afa0d9647a6d7cba3aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Srokosz?= Date: Thu, 9 Jan 2025 14:38:48 +0100 Subject: [PATCH] Allow dots in user and group names (#1014) --- mwdb/schema/group.py | 8 ++++---- mwdb/schema/share.py | 4 ++-- mwdb/schema/user.py | 4 ++-- .../web/src/components/Settings/Views/GroupCreateView.tsx | 4 ++-- .../src/components/Settings/Views/GroupDetailsView.tsx | 2 +- mwdb/web/src/components/Settings/Views/UserCreateView.tsx | 4 ++-- mwdb/web/src/components/Views/UserRegisterView.tsx | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mwdb/schema/group.py b/mwdb/schema/group.py index 5c11752fa..fa8e508c8 100644 --- a/mwdb/schema/group.py +++ b/mwdb/schema/group.py @@ -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") @@ -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" ) diff --git a/mwdb/schema/share.py b/mwdb/schema/share.py index 16d583d5c..980dc97e9 100644 --- a/mwdb/schema/share.py +++ b/mwdb/schema/share.py @@ -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" ) diff --git a/mwdb/schema/user.py b/mwdb/schema/user.py index 8b59f20e9..9269694fa 100644 --- a/mwdb/schema/user.py +++ b/mwdb/schema/user.py @@ -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") diff --git a/mwdb/web/src/components/Settings/Views/GroupCreateView.tsx b/mwdb/web/src/components/Settings/Views/GroupCreateView.tsx index 604985efd..a30ea4158 100644 --- a/mwdb/web/src/components/Settings/Views/GroupCreateView.tsx +++ b/mwdb/web/src/components/Settings/Views/GroupCreateView.tsx @@ -13,8 +13,8 @@ type FormValues = { const validationSchema: Yup.SchemaOf = 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"), diff --git a/mwdb/web/src/components/Settings/Views/GroupDetailsView.tsx b/mwdb/web/src/components/Settings/Views/GroupDetailsView.tsx index 35aa9793c..7b3c0ee66 100644 --- a/mwdb/web/src/components/Settings/Views/GroupDetailsView.tsx +++ b/mwdb/web/src/components/Settings/Views/GroupDetailsView.tsx @@ -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}" /> diff --git a/mwdb/web/src/components/Settings/Views/UserCreateView.tsx b/mwdb/web/src/components/Settings/Views/UserCreateView.tsx index bb3443bf0..f58a8f692 100644 --- a/mwdb/web/src/components/Settings/Views/UserCreateView.tsx +++ b/mwdb/web/src/components/Settings/Views/UserCreateView.tsx @@ -12,8 +12,8 @@ type FormValues = CreateUser; const validationSchema: Yup.SchemaOf = 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"), diff --git a/mwdb/web/src/components/Views/UserRegisterView.tsx b/mwdb/web/src/components/Views/UserRegisterView.tsx index 55bca7c7e..89a0d0a37 100644 --- a/mwdb/web/src/components/Views/UserRegisterView.tsx +++ b/mwdb/web/src/components/Views/UserRegisterView.tsx @@ -25,8 +25,8 @@ const validationSchema: Yup.SchemaOf = 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")