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

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

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

Loading…
Cancel
Save