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
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -106,6 +106,15 @@ export default React.createClass({
}, },
_doUsernameCheck: function() { _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 // Check if username is available
return this._matrixClient.isUsernameAvailable(this.state.username).then( return this._matrixClient.isUsernameAvailable(this.state.username).then(
(isAvailable) => { (isAvailable) => {