Prevent illegal username and passwords

pull/740/head
Vincent 5 years ago
parent 4d690768a6
commit 0a525629ee

@ -29,5 +29,4 @@
return this; return this;
}, },
}); });
})(); })();

@ -59,6 +59,11 @@ window.isBeforeVersion = (toCheck, baseVersion) => {
} }
}; };
window.CONSTANTS = {
maxPasswordLength: 32,
maxUsernameLength: 20,
};
window.versionInfo = { window.versionInfo = {
environment: window.getEnvironment(), environment: window.getEnvironment(),
version: window.getVersion(), version: window.getVersion(),

@ -32,8 +32,12 @@
} }
@keyframes fadein { @keyframes fadein {
from {opacity: 0;} from {
to {opacity: 1;} opacity: 0;
}
to {
opacity: 1;
}
} }
// Session Colors // Session Colors
@ -154,7 +158,7 @@ div.spacer-lg {
} }
$session-transition-duration: 0.25s; $session-transition-duration: 0.25s;
$session-fadein-duration: 0.10s; $session-fadein-duration: 0.1s;
$session-icon-size-sm: 15px; $session-icon-size-sm: 15px;
$session-icon-size-md: 20px; $session-icon-size-md: 20px;

@ -208,6 +208,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
value={this.state.profileName} value={this.state.profileName}
placeholder={placeholderText} placeholder={placeholderText}
onChange={this.onNameEdited} onChange={this.onNameEdited}
maxLength={window.CONSTANTS.maxUsernameLength}
tabIndex={0} tabIndex={0}
required={true} required={true}
aria-required={true} aria-required={true}
@ -260,10 +261,10 @@ export class EditProfileDialog extends React.Component<Props, State> {
); );
} }
private onNameEdited(e: any) { private onNameEdited(event: any) {
e.persist(); event.persist();
const newName = e.target.value.replace(window.displayNameRegex, ''); const newName = event.target.value.replace(window.displayNameRegex, '');
this.setState(state => { this.setState(state => {
return { return {
@ -301,7 +302,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
private onClickOK() { private onClickOK() {
const newName = this.state.profileName.trim(); const newName = this.state.profileName.trim();
if (newName === '') { if (newName.length === 0 || newName.length > window.CONSTANTS.maxUsernameLength) {
return; return;
} }

@ -218,33 +218,4 @@ export class LeftPaneSettingSection extends React.Component<any, State> {
settingCategory: category, settingCategory: category,
}); });
} }
// public updateSearch(searchTerm: string) {
// const { updateSearchTerm, clearSearch } = this.props;
// if (!searchTerm) {
// clearSearch();
// return;
// }
// // reset our pubKeyPasted, we can either have a pasted sessionID or a sessionID got from a search
// this.setState({ pubKeyPasted: '' }, () => {
// window.Session.emptyContentEditableDivs();
// });
// if (updateSearchTerm) {
// updateSearchTerm(searchTerm);
// }
// if (searchTerm.length < 2) {
// return;
// }
// const cleanedTerm = cleanSearchTerm(searchTerm);
// if (!cleanedTerm) {
// return;
// }
// this.debouncedSearch(cleanedTerm);
// }
} }

@ -449,6 +449,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
type="text" type="text"
placeholder={window.i18n('enterDisplayName')} placeholder={window.i18n('enterDisplayName')}
value={this.state.displayName} value={this.state.displayName}
maxLength={window.CONSTANTS.maxUsernameLength}
onValueChanged={(val: string) => { onValueChanged={(val: string) => {
this.onDisplayNameChanged(val); this.onDisplayNameChanged(val);
}} }}
@ -462,6 +463,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
error={this.state.passwordErrorString} error={this.state.passwordErrorString}
type="password" type="password"
placeholder={window.i18n('enterOptionalPassword')} placeholder={window.i18n('enterOptionalPassword')}
maxLength={window.CONSTANTS.maxPasswordLength}
onValueChanged={(val: string) => { onValueChanged={(val: string) => {
this.onPasswordChanged(val); this.onPasswordChanged(val);
}} }}
@ -475,6 +477,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
error={passwordsDoNotMatch} error={passwordsDoNotMatch}
type="password" type="password"
placeholder={window.i18n('optionalPassword')} placeholder={window.i18n('optionalPassword')}
maxLength={window.CONSTANTS.maxPasswordLength}
onValueChanged={(val: string) => { onValueChanged={(val: string) => {
this.onPasswordVerifyChanged(val); this.onPasswordVerifyChanged(val);
}} }}

@ -9,6 +9,7 @@ interface Props {
type: string; type: string;
value?: string; value?: string;
placeholder: string; placeholder: string;
maxLength?: number;
enableShowHide?: boolean; enableShowHide?: boolean;
onValueChanged?: any; onValueChanged?: any;
onEnterPressed?: any; onEnterPressed?: any;
@ -33,7 +34,7 @@ export class SessionInput extends React.PureComponent<Props, State> {
} }
public render() { public render() {
const { placeholder, type, value, enableShowHide, error } = this.props; const { placeholder, type, value, maxLength, enableShowHide, error } = this.props;
const { forceShow } = this.state; const { forceShow } = this.state;
const correctType = forceShow ? 'text' : type; const correctType = forceShow ? 'text' : type;
@ -46,6 +47,7 @@ export class SessionInput extends React.PureComponent<Props, State> {
type={correctType} type={correctType}
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
maxLength={maxLength}
onChange={e => { onChange={e => {
this.updateInputValue(e); this.updateInputValue(e);
}} }}

@ -58,12 +58,14 @@ export class SessionPasswordModal extends React.Component<Props, State> {
type="password" type="password"
id="password-modal-input" id="password-modal-input"
placeholder={placeholders[0]} placeholder={placeholders[0]}
maxLength={window.CONSTANTS.maxPasswordLength}
/> />
{action !== PasswordAction.Remove && ( {action !== PasswordAction.Remove && (
<input <input
type="password" type="password"
id="password-modal-input-confirm" id="password-modal-input-confirm"
placeholder={placeholders[1]} placeholder={placeholders[1]}
maxLength={window.CONSTANTS.maxPasswordLength}
/> />
)} )}
</div> </div>
@ -118,6 +120,10 @@ export class SessionPasswordModal extends React.Component<Props, State> {
$('#password-modal-input-confirm').val() $('#password-modal-input-confirm').val()
); );
if (enteredPassword.length === 0 || enteredPasswordConfirm.length === 0){
return;
}
// Check passwords enntered // Check passwords enntered
if ( if (
enteredPassword.length === 0 || enteredPassword.length === 0 ||

@ -3,7 +3,7 @@ import React from 'react';
import { SessionIconButton, SessionIconType, SessionIconSize } from './icon'; import { SessionIconButton, SessionIconType, SessionIconSize } from './icon';
interface Props { interface Props {
count: number, count: number;
} }
export class SessionScrollButton extends React.PureComponent<Props> { export class SessionScrollButton extends React.PureComponent<Props> {
@ -12,13 +12,11 @@ export class SessionScrollButton extends React.PureComponent<Props> {
} }
public render() { public render() {
console.log(`My count is: ${this.props.count}`);
return ( return (
<SessionIconButton <SessionIconButton
iconType={SessionIconType.Chevron} iconType={SessionIconType.Chevron}
iconSize={SessionIconSize.Huge} iconSize={SessionIconSize.Huge}
iconColor={"#FFFFFF"} iconColor={'#FFFFFF'}
/> />
); );
} }

@ -15,6 +15,7 @@ export enum SessionSettingCategory {
Permissions = 'permissions', Permissions = 'permissions',
Notifications = 'notifications', Notifications = 'notifications',
Devices = 'devices', Devices = 'devices',
Blocked = 'blocked',
} }
export enum SessionSettingType { export enum SessionSettingType {
@ -396,7 +397,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
id: 'media-permissions', id: 'media-permissions',
title: window.i18n('mediaPermissionsTitle'), title: window.i18n('mediaPermissionsTitle'),
description: window.i18n('mediaPermissionsDescription'), description: window.i18n('mediaPermissionsDescription'),
hidden: false, hidden: true, // Hidden until feature works
type: SessionSettingType.Toggle, type: SessionSettingType.Toggle,
category: SessionSettingCategory.Permissions, category: SessionSettingCategory.Permissions,
setFn: window.toggleMediaPermissions, setFn: window.toggleMediaPermissions,

1
ts/global.d.ts vendored

@ -1,4 +1,5 @@
interface Window { interface Window {
CONSTANTS: any;
versionInfo: any; versionInfo: any;
Events: any; Events: any;

Loading…
Cancel
Save