From e6077d0dc3e2426d771cf81ed5e2e387c2348649 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 17 Nov 2020 19:14:55 +0100 Subject: [PATCH] Forbid creating usernames with uppercase characters We don't actually enforce anything on the ActivityPub level, only user-facing interfaces Signed-off-by: Thomas Citharel --- js/src/i18n/en_US.json | 2 +- js/src/i18n/fr_FR.json | 2 +- js/src/views/Account/Register.vue | 13 +- .../views/Account/children/EditIdentity.vue | 4 +- js/src/views/Group/Create.vue | 25 +- js/tests/e2e/specs/login.js | 2 +- lib/graphql/resolvers/group.ex | 1 + lib/graphql/resolvers/person.ex | 4 +- lib/mobilizon/actors/actor.ex | 7 +- priv/gettext/ar/LC_MESSAGES/default.po | 18 +- priv/gettext/ar/LC_MESSAGES/errors.po | 138 +- priv/gettext/be/LC_MESSAGES/default.po | 18 +- priv/gettext/be/LC_MESSAGES/errors.po | 138 +- priv/gettext/ca/LC_MESSAGES/default.po | 480 +++--- priv/gettext/ca/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/cs/LC_MESSAGES/default.po | 18 +- priv/gettext/cs/LC_MESSAGES/errors.po | 138 +- priv/gettext/de/LC_MESSAGES/default.po | 18 +- priv/gettext/de/LC_MESSAGES/errors.po | 138 +- priv/gettext/default.pot | 16 +- priv/gettext/en/LC_MESSAGES/default.po | 18 +- priv/gettext/en/LC_MESSAGES/errors.po | 138 +- priv/gettext/errors.pot | 138 +- priv/gettext/es/LC_MESSAGES/default.po | 480 +++--- priv/gettext/es/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/fi/LC_MESSAGES/default.po | 480 +++--- priv/gettext/fi/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/fr/LC_MESSAGES/default.po | 426 ++++- priv/gettext/fr/LC_MESSAGES/errors.po | 134 +- priv/gettext/gl/LC_MESSAGES/default.po | 480 +++--- priv/gettext/gl/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/hu/LC_MESSAGES/default.po | 1369 +++++++++++++++++ priv/gettext/hu/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/it/LC_MESSAGES/default.po | 480 +++--- priv/gettext/it/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/ja/LC_MESSAGES/default.po | 18 +- priv/gettext/ja/LC_MESSAGES/errors.po | 138 +- priv/gettext/nl/LC_MESSAGES/default.po | 18 +- priv/gettext/nl/LC_MESSAGES/errors.po | 138 +- priv/gettext/nn/LC_MESSAGES/default.po | 480 +++--- priv/gettext/nn/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/oc/LC_MESSAGES/default.po | 480 +++--- priv/gettext/oc/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/pl/LC_MESSAGES/default.po | 480 +++--- priv/gettext/pl/LC_MESSAGES/errors.po | 326 ++-- priv/gettext/pt/LC_MESSAGES/default.po | 18 +- priv/gettext/pt/LC_MESSAGES/errors.po | 138 +- priv/gettext/pt_BR/LC_MESSAGES/default.po | 18 +- priv/gettext/pt_BR/LC_MESSAGES/errors.po | 138 +- priv/gettext/ru/LC_MESSAGES/default.po | 18 +- priv/gettext/ru/LC_MESSAGES/errors.po | 138 +- priv/gettext/sv/LC_MESSAGES/default.po | 18 +- priv/gettext/sv/LC_MESSAGES/errors.po | 138 +- test/graphql/resolvers/user_test.exs | 601 +++----- test/mobilizon/actors/actors_test.exs | 10 +- 55 files changed, 6436 insertions(+), 4808 deletions(-) create mode 100644 priv/gettext/hu/LC_MESSAGES/default.po diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index bfe0ce95f..918c1a7d6 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -231,7 +231,7 @@ "On {date} starting at {startTime}": "On {date} starting at {startTime}", "On {date}": "On {date}", "Only accessible through link (private)": "Only accessible through link (private)", - "Only alphanumeric characters and underscores are supported.": "Only alphanumeric characters and underscores are supported.", + "Only alphanumeric lowercased characters and underscores are supported.": "Only alphanumeric lowercased characters and underscores are supported.", "Open": "Open", "Opened reports": "Opened reports", "Or": "Or", diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 5dda93cf1..34663c42c 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -480,7 +480,7 @@ "Only accessible through link": "Accessible uniquement par le lien", "Only accessible through link (private)": "Uniquement accessible par lien (privé)", "Only accessible to members of the group": "Accessible uniquement aux membres du groupe", - "Only alphanumeric characters and underscores are supported.": "Seuls les caractères alphanumériques et les tirets bas sont acceptés.", + "Only alphanumeric lowercased characters and underscores are supported.": "Seuls les caractères alphanumériques minuscules et les tirets bas sont acceptés.", "Only group moderators can create, edit and delete posts.": "Seul·e·s les modérateur·rice·s du groupe peuvent créer, éditer et supprimer des billets.", "Open": "Ouvert", "Opened reports": "Signalements ouverts", diff --git a/js/src/views/Account/Register.vue b/js/src/views/Account/Register.vue index fcb1fd319..3d60c96bc 100644 --- a/js/src/views/Account/Register.vue +++ b/js/src/views/Account/Register.vue @@ -26,12 +26,21 @@ :type="errors.preferred_username ? 'is-danger' : null" :message="errors.preferred_username" > - +

@{{ host }} @@ -164,7 +173,7 @@ export default class Register extends mixins(identityEditionMixin) { } catch (errorCatched) { this.errors = errorCatched.graphQLErrors.reduce( (acc: { [key: string]: string }, error: any) => { - acc[error.details] = error.message; + acc[error.details || error.field] = error.message; return acc; }, {} diff --git a/js/src/views/Account/children/EditIdentity.vue b/js/src/views/Account/children/EditIdentity.vue index dcb45e14f..6054c1e22 100644 --- a/js/src/views/Account/children/EditIdentity.vue +++ b/js/src/views/Account/children/EditIdentity.vue @@ -181,7 +181,9 @@ export default class EditIdentity extends mixins(identityEditionMixin) { get message(): string | null { if (this.isUpdate) return null; - return this.$t("Only alphanumeric characters and underscores are supported.") as string; + return this.$t( + "Only alphanumeric lowercased characters and underscores are supported." + ) as string; } get avatarUrl(): string | null { diff --git a/js/src/views/Group/Create.vue b/js/src/views/Group/Create.vue index 7ac235de1..b6ae99f40 100644 --- a/js/src/views/Group/Create.vue +++ b/js/src/views/Group/Create.vue @@ -1,6 +1,6 @@