Skip to content

Commit bac9675

Browse files
authored
Merge pull request #4478 from aman-atg/aman-atg-secondaryLoginFix
don't allow invalid characters
2 parents 2b48ffb + efb4807 commit bac9675

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/pages/settings/AddSecondaryLoginPage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class AddSecondaryLoginPage extends Component {
7272
};
7373
this.formType = props.route.params.type;
7474
this.submitForm = this.submitForm.bind(this);
75+
this.onSecondaryLoginChange = this.onSecondaryLoginChange.bind(this);
7576
this.validateForm = this.validateForm.bind(this);
7677

7778
this.phoneNumberInputRef = null;
@@ -81,6 +82,15 @@ class AddSecondaryLoginPage extends Component {
8182
Onyx.merge(ONYXKEYS.USER, {error: ''});
8283
}
8384

85+
onSecondaryLoginChange(login) {
86+
if (this.formType === CONST.LOGIN_TYPE.EMAIL) {
87+
this.setState({login});
88+
} else if (this.formType === CONST.LOGIN_TYPE.PHONE
89+
&& (CONST.REGEX.DIGITS_AND_PLUS.test(login) || login === '')) {
90+
this.setState({login});
91+
}
92+
}
93+
8494
/**
8595
* Add a secondary login to a user's account
8696
*/
@@ -133,7 +143,7 @@ class AddSecondaryLoginPage extends Component {
133143
: 'profilePage.emailAddress')}
134144
ref={el => this.phoneNumberInputRef = el}
135145
value={this.state.login}
136-
onChangeText={login => this.setState({login})}
146+
onChangeText={this.onSecondaryLoginChange}
137147
keyboardType={this.formType === CONST.LOGIN_TYPE.PHONE
138148
? CONST.KEYBOARD_TYPE.PHONE_PAD : undefined}
139149
returnKeyType="done"

0 commit comments

Comments
 (0)