Skip to content

Commit a1eceeb

Browse files
authored
Merge pull request #6433 from parasharrajat/login-userna,e
fix: Secondary login page
2 parents 2cc98c7 + d9e523c commit a1eceeb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/pages/settings/AddSecondaryLoginPage.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import compose from '../../libs/compose';
2020
import FixedFooter from '../../components/FixedFooter';
2121
import ExpensiTextInput from '../../components/ExpensiTextInput';
2222
import userPropTypes from './userPropTypes';
23+
import LoginUtil from '../../libs/LoginUtil';
2324

2425
const propTypes = {
2526
/* Onyx Props */
@@ -63,19 +64,17 @@ class AddSecondaryLoginPage extends Component {
6364
}
6465

6566
onSecondaryLoginChange(login) {
66-
if (this.formType === CONST.LOGIN_TYPE.EMAIL) {
67-
this.setState({login});
68-
} else if (this.formType === CONST.LOGIN_TYPE.PHONE
69-
&& (CONST.REGEX.DIGITS_AND_PLUS.test(login) || login === '')) {
70-
this.setState({login});
71-
}
67+
this.setState({login});
7268
}
7369

7470
/**
7571
* Add a secondary login to a user's account
7672
*/
7773
submitForm() {
78-
User.setSecondaryLoginAndNavigate(this.state.login, this.state.password);
74+
const login = this.formType === CONST.LOGIN_TYPE.PHONE
75+
? LoginUtil.getPhoneNumberWithoutSpecialChars(this.state.login)
76+
: this.state.login;
77+
User.setSecondaryLoginAndNavigate(login, this.state.password);
7978
}
8079

8180
/**
@@ -84,8 +83,12 @@ class AddSecondaryLoginPage extends Component {
8483
* @returns {Boolean}
8584
*/
8685
validateForm() {
86+
const login = this.formType === CONST.LOGIN_TYPE.PHONE
87+
? LoginUtil.getPhoneNumberWithoutSpecialChars(this.state.login)
88+
: this.state.login;
89+
8790
const validationMethod = this.formType === CONST.LOGIN_TYPE.PHONE ? Str.isValidPhone : Str.isValidEmail;
88-
return !this.state.password || !validationMethod(this.state.login);
91+
return !this.state.password || !validationMethod(login);
8992
}
9093

9194
render() {

0 commit comments

Comments
 (0)