@@ -20,6 +20,7 @@ import compose from '../../libs/compose';
20
20
import FixedFooter from '../../components/FixedFooter' ;
21
21
import ExpensiTextInput from '../../components/ExpensiTextInput' ;
22
22
import userPropTypes from './userPropTypes' ;
23
+ import LoginUtil from '../../libs/LoginUtil' ;
23
24
24
25
const propTypes = {
25
26
/* Onyx Props */
@@ -63,19 +64,17 @@ class AddSecondaryLoginPage extends Component {
63
64
}
64
65
65
66
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} ) ;
72
68
}
73
69
74
70
/**
75
71
* Add a secondary login to a user's account
76
72
*/
77
73
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 ) ;
79
78
}
80
79
81
80
/**
@@ -84,8 +83,12 @@ class AddSecondaryLoginPage extends Component {
84
83
* @returns {Boolean }
85
84
*/
86
85
validateForm ( ) {
86
+ const login = this . formType === CONST . LOGIN_TYPE . PHONE
87
+ ? LoginUtil . getPhoneNumberWithoutSpecialChars ( this . state . login )
88
+ : this . state . login ;
89
+
87
90
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 ) ;
89
92
}
90
93
91
94
render ( ) {
0 commit comments