1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-17 17:42:41 +03:00

copy logic from RegistrationForm to detect invalid localparts

This commit is contained in:
Michael Telatynski
2017-07-31 13:28:43 +01:00
parent 8fd0ced215
commit 25d1d21d93

View File

@@ -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) => {