allow space inside a display name but not at start or end

pull/744/head
Audric Ackermann 5 years ago
parent 5c4fa1d2cb
commit c92d22fece
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1351,7 +1351,6 @@ class LokiPublicChannelAPI {
// process remaining messages
slaveMessages.forEach(messageData => {
const slaveKey = messageData.source;
// prevent our own device sent messages from coming back in
@ -1377,7 +1376,6 @@ class LokiPublicChannelAPI {
this.chatAPI.emit('publicMessage', {
message: messageData,
});
});
// if we received one of our own messages

@ -217,11 +217,11 @@ export class RegistrationTabs extends React.Component<{}, State> {
private onDisplayNameChanged(val: string) {
const sanitizedName = this.sanitiseNameInput(val);
const trimName = sanitizedName.trim();
this.setState({
displayName: sanitizedName,
displayNameError: !sanitizedName
? window.i18n('displayNameEmpty')
: undefined,
displayNameError: !trimName ? window.i18n('displayNameEmpty') : undefined,
});
}
@ -553,10 +553,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
}
private renderTermsConditionAgreement() {
// FIXME
window.log.info(
'FIXME: add link to our Terms and Conditions and privacy statement'
);
// FIXME add link to our Terms and Conditions and privacy statement
return (
<div className="session-terms-conditions-agreement">
@ -713,7 +710,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
}
private sanitiseNameInput(val: string) {
return val.trim().replace(window.displayNameRegex, '');
return val.replace(window.displayNameRegex, '');
}
private async resetRegistration() {
@ -738,6 +735,19 @@ export class RegistrationTabs extends React.Component<{}, State> {
passwordFieldsMatch,
} = this.state;
// Make sure the password is valid
const trimName = displayName.trim();
if (!trimName) {
window.pushToast({
title: window.i18n('displayNameEmpty'),
type: 'error',
id: 'invalidDisplayName',
});
return;
}
if (passwordErrorString) {
window.pushToast({
title: window.i18n('invalidPassword'),
@ -761,9 +771,6 @@ export class RegistrationTabs extends React.Component<{}, State> {
if (!mnemonicSeed) {
return;
}
if (!displayName) {
return;
}
// Ensure we clear the secondary device registration status
window.textsecure.storage.remove('secondaryDeviceStatus');
@ -775,7 +782,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
await this.accountManager.registerSingleDevice(
mnemonicSeed,
language,
displayName
trimName
);
trigger('openInbox');
} catch (e) {

Loading…
Cancel
Save