From 25d1d21d93c9508fd3ae92f458452385e4c1bb41 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Jul 2017 13:28:43 +0100 Subject: [PATCH 1/4] copy logic from RegistrationForm to detect invalid localparts --- src/components/views/dialogs/SetMxIdDialog.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/views/dialogs/SetMxIdDialog.js b/src/components/views/dialogs/SetMxIdDialog.js index 4d4f672f2b..6c3b1516d0 100644 --- a/src/components/views/dialogs/SetMxIdDialog.js +++ b/src/components/views/dialogs/SetMxIdDialog.js @@ -106,6 +106,15 @@ export default React.createClass({ }, _doUsernameCheck: function() { + // XXX: SPEC-1 + // Check if username is valid + if (encodeURIComponent(this.state.username) !== this.state.username) { + this.setState({ + usernameError: _t('User names may only contain letters, numbers, dots, hyphens and underscores.'), + }); + return Promise.resolve(); + } + // Check if username is available return this._matrixClient.isUsernameAvailable(this.state.username).then( (isAvailable) => { From f310d4446ca36be243bb92c5cfcc442a5e58aca1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Jul 2017 13:31:07 +0100 Subject: [PATCH 2/4] i18n the title of the set mxid dialog --- src/components/views/dialogs/SetMxIdDialog.js | 2 +- src/i18n/strings/en_EN.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/SetMxIdDialog.js b/src/components/views/dialogs/SetMxIdDialog.js index 6c3b1516d0..2462f24a87 100644 --- a/src/components/views/dialogs/SetMxIdDialog.js +++ b/src/components/views/dialogs/SetMxIdDialog.js @@ -251,7 +251,7 @@ export default React.createClass({ return (
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7b027b6417..fd70a49311 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -571,6 +571,7 @@ "To configure the room": "To configure the room", "to demote": "to demote", "to favourite": "to favourite", + "To get started, please pick a username!": "To get started, please pick a username!", "To invite users into the room": "To invite users into the room", "To kick users": "To kick users", "To link to a room it must have an address.": "To link to a room it must have an address.", From 62af06104dd2492b0ac5a0cf1f20b64b1ceec19e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Jul 2017 14:22:05 +0100 Subject: [PATCH 3/4] resolve -> reject because semantics. --- src/components/views/dialogs/SetMxIdDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/SetMxIdDialog.js b/src/components/views/dialogs/SetMxIdDialog.js index 2462f24a87..9fb6b838b2 100644 --- a/src/components/views/dialogs/SetMxIdDialog.js +++ b/src/components/views/dialogs/SetMxIdDialog.js @@ -112,7 +112,7 @@ export default React.createClass({ this.setState({ usernameError: _t('User names may only contain letters, numbers, dots, hyphens and underscores.'), }); - return Promise.resolve(); + return Promise.reject(); } // Check if username is available From 579090a4e307cd38403c7fed163f73b615d34c62 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Wed, 9 Aug 2017 16:37:38 +0100 Subject: [PATCH 4/4] add comment --- src/components/views/dialogs/SetMxIdDialog.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/dialogs/SetMxIdDialog.js b/src/components/views/dialogs/SetMxIdDialog.js index 9fb6b838b2..554a244358 100644 --- a/src/components/views/dialogs/SetMxIdDialog.js +++ b/src/components/views/dialogs/SetMxIdDialog.js @@ -108,6 +108,7 @@ export default React.createClass({ _doUsernameCheck: function() { // XXX: SPEC-1 // Check if username is valid + // Naive impl copied from https://github.com/matrix-org/matrix-react-sdk/blob/66c3a6d9ca695780eb6b662e242e88323053ff33/src/components/views/login/RegistrationForm.js#L190 if (encodeURIComponent(this.state.username) !== this.state.username) { this.setState({ usernameError: _t('User names may only contain letters, numbers, dots, hyphens and underscores.'),