Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2018-12-14 05:09:54 +00:00
commit 8004e1b23f
6 changed files with 17 additions and 16 deletions

View file

@ -26,6 +26,10 @@ import MatrixClientPeg from './MatrixClientPeg';
import Modal from './Modal'; import Modal from './Modal';
import { _t } from './languageHandler'; import { _t } from './languageHandler';
// Regex for what a "safe" or "Matrix-looking" localpart would be.
// TODO: Update as needed for https://github.com/matrix-org/matrix-doc/issues/1514
export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/;
/** /**
* Starts either the ILAG or full registration flow, depending * Starts either the ILAG or full registration flow, depending
* on what the HS supports * on what the HS supports

View file

@ -342,7 +342,7 @@ module.exports = React.createClass({
errMsg = _t('A phone number is required to register on this homeserver.'); errMsg = _t('A phone number is required to register on this homeserver.');
break; break;
case "RegistrationForm.ERR_USERNAME_INVALID": case "RegistrationForm.ERR_USERNAME_INVALID":
errMsg = _t('User names may only contain letters, numbers, dots, hyphens and underscores.'); errMsg = _t("Only use lower case letters, numbers and '=_-./'");
break; break;
case "RegistrationForm.ERR_USERNAME_BLANK": case "RegistrationForm.ERR_USERNAME_BLANK":
errMsg = _t('You need to enter a user name.'); errMsg = _t('You need to enter a user name.');

View file

@ -23,6 +23,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg';
import classnames from 'classnames'; import classnames from 'classnames';
import { KeyCode } from '../../../Keyboard'; import { KeyCode } from '../../../Keyboard';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { SAFE_LOCALPART_REGEX } from '../../../Registration';
// The amount of time to wait for further changes to the input username before // The amount of time to wait for further changes to the input username before
// sending a request to the server // sending a request to the server
@ -110,12 +111,11 @@ export default React.createClass({
}, },
_doUsernameCheck: function() { _doUsernameCheck: function() {
// XXX: SPEC-1 // We do a quick check ahead of the username availability API to ensure the
// Check if username is valid // user ID roughly looks okay from a Matrix perspective.
// Naive impl copied from https://github.com/matrix-org/matrix-react-sdk/blob/66c3a6d9ca695780eb6b662e242e88323053ff33/src/components/views/login/RegistrationForm.js#L190 if (!SAFE_LOCALPART_REGEX.test(this.state.username)) {
if (encodeURIComponent(this.state.username) !== this.state.username) {
this.setState({ this.setState({
usernameError: _t('User names may only contain letters, numbers, dots, hyphens and underscores.'), usernameError: _t("Only use lower case letters, numbers and '=_-./'"),
}); });
return Promise.reject(); return Promise.reject();
} }
@ -210,7 +210,6 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const InteractiveAuth = sdk.getComponent('structures.InteractiveAuth'); const InteractiveAuth = sdk.getComponent('structures.InteractiveAuth');
const Spinner = sdk.getComponent('elements.Spinner');
let auth; let auth;
if (this.state.doingUIAuth) { if (this.state.doingUIAuth) {
@ -230,9 +229,8 @@ export default React.createClass({
}); });
let usernameIndicator = null; let usernameIndicator = null;
let usernameBusyIndicator = null;
if (this.state.usernameBusy) { if (this.state.usernameBusy) {
usernameBusyIndicator = <Spinner w="24" h="24" />; usernameIndicator = <div>{_t("Checking...")}</div>;
} else { } else {
const usernameAvailable = this.state.username && const usernameAvailable = this.state.username &&
this.state.usernameCheckSupport && !this.state.usernameError; this.state.usernameCheckSupport && !this.state.usernameError;
@ -270,7 +268,6 @@ export default React.createClass({
size="30" size="30"
className={inputClasses} className={inputClasses}
/> />
{ usernameBusyIndicator }
</div> </div>
{ usernameIndicator } { usernameIndicator }
<p> <p>

View file

@ -25,7 +25,7 @@ import { looksValid as phoneNumberLooksValid } from '../../../phonenumber';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
import SettingsStore from "../../../settings/SettingsStore"; import { SAFE_LOCALPART_REGEX } from '../../../Registration';
const FIELD_EMAIL = 'field_email'; const FIELD_EMAIL = 'field_email';
const FIELD_PHONE_COUNTRY = 'field_phone_country'; const FIELD_PHONE_COUNTRY = 'field_phone_country';
@ -194,9 +194,8 @@ module.exports = React.createClass({
} else this.markFieldValid(field_id, phoneNumberValid, "RegistrationForm.ERR_PHONE_NUMBER_INVALID"); } else this.markFieldValid(field_id, phoneNumberValid, "RegistrationForm.ERR_PHONE_NUMBER_INVALID");
break; break;
case FIELD_USERNAME: case FIELD_USERNAME:
// XXX: SPEC-1 const username = this.refs.username.value.trim();
var username = this.refs.username.value.trim(); if (!SAFE_LOCALPART_REGEX.test(username)) {
if (encodeURIComponent(username) != username) {
this.markFieldValid( this.markFieldValid(
field_id, field_id,
false, false,

View file

@ -130,7 +130,7 @@ module.exports = React.createClass({
}, },
isAliasValid: function(alias) { isAliasValid: function(alias) {
// XXX: FIXME SPEC-1 // XXX: FIXME https://github.com/matrix-org/matrix-doc/issues/668
return (alias.match(/^#([^\/:,]+?):(.+)$/) && encodeURI(alias) === alias); return (alias.match(/^#([^\/:,]+?):(.+)$/) && encodeURI(alias) === alias);
}, },

View file

@ -985,10 +985,11 @@
"Unable to verify email address.": "Unable to verify email address.", "Unable to verify email address.": "Unable to verify email address.",
"This will allow you to reset your password and receive notifications.": "This will allow you to reset your password and receive notifications.", "This will allow you to reset your password and receive notifications.": "This will allow you to reset your password and receive notifications.",
"Skip": "Skip", "Skip": "Skip",
"User names may only contain letters, numbers, dots, hyphens and underscores.": "User names may only contain letters, numbers, dots, hyphens and underscores.", "Only use lower case letters, numbers and '=_-./'": "Only use lower case letters, numbers and '=_-./'",
"Username not available": "Username not available", "Username not available": "Username not available",
"Username invalid: %(errMessage)s": "Username invalid: %(errMessage)s", "Username invalid: %(errMessage)s": "Username invalid: %(errMessage)s",
"An error occurred: %(error_string)s": "An error occurred: %(error_string)s", "An error occurred: %(error_string)s": "An error occurred: %(error_string)s",
"Checking...": "Checking...",
"Username available": "Username available", "Username available": "Username available",
"To get started, please pick a username!": "To get started, please pick a username!", "To get started, please pick a username!": "To get started, please pick a username!",
"This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.": "This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.", "This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.": "This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.",