Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove in-app password requirement for passwordless users #15338

Merged
merged 5 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ export default {
addSecondaryLoginPage: {
addPhoneNumber: 'Add phone number',
addEmailAddress: 'Add email address',
enterPreferredPhoneNumberToSendValidationLink: 'Enter your preferred phone number and password to send a validation link.',
enterPreferredEmailToSendValidationLink: 'Enter your preferred email address and password to send a validation link.',
enterPreferredPhoneNumberToSendValidationLink: 'Enter your preferred phone number to send a validation link.',
enterPreferredEmailToSendValidationLink: 'Enter your preferred email address to send a validation link.',
sendValidation: 'Send validation',
},
initialSettingsPage: {
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ export default {
addSecondaryLoginPage: {
addPhoneNumber: 'Agregar número de teléfono',
addEmailAddress: 'Agregar dirección de email',
enterPreferredPhoneNumberToSendValidationLink: 'Escribe tu número de teléfono y contraseña para recibir el enlace de validación.',
enterPreferredEmailToSendValidationLink: 'Escribe tu email y contraseña para recibir el enlace de validación.',
enterPreferredPhoneNumberToSendValidationLink: 'Escribe tu número de teléfono para recibir el enlace de validación.',
enterPreferredEmailToSendValidationLink: 'Escribe tu email para recibir el enlace de validación.',
sendValidation: 'Enviar validación',
},
initialSettingsPage: {
Expand Down
30 changes: 20 additions & 10 deletions src/pages/settings/Payments/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ import ONYXKEYS from '../../../ONYXKEYS';
import AddressSearch from '../../../components/AddressSearch';
import * as ComponentUtils from '../../../libs/ComponentUtils';
import Form from '../../../components/Form';
import Permissions from '../../../libs/Permissions';

const propTypes = {
/* Onyx Props */
formData: PropTypes.shape({
setupComplete: PropTypes.bool,
}),

/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),

...withLocalizePropTypes,
};

const defaultProps = {
formData: {
setupComplete: false,
},
betas: [],
};

class DebitCardPage extends Component {
Expand Down Expand Up @@ -95,7 +100,7 @@ class DebitCardPage extends Component {
errors.addressState = this.props.translate('addDebitCardPage.error.addressState');
}

if (!values.password || _.isEmpty(values.password.trim())) {
if (!Permissions.canUsePasswordlessLogins(this.props.betas) && (!values.password || _.isEmpty(values.password.trim()))) {
errors.password = this.props.translate('addDebitCardPage.error.password');
}

Expand Down Expand Up @@ -176,15 +181,17 @@ class DebitCardPage extends Component {
/>
</View>
</View>
<View style={[styles.mt4]}>
<TextInput
inputID="password"
label={this.props.translate('addDebitCardPage.expensifyPassword')}
textContentType="password"
autoCompleteType={ComponentUtils.PASSWORD_AUTOCOMPLETE_TYPE}
secureTextEntry
/>
</View>
{!Permissions.canUsePasswordlessLogins(this.props.betas) && (
<View style={[styles.mt4]}>
<TextInput
inputID="password"
label={this.props.translate('addDebitCardPage.expensifyPassword')}
textContentType="password"
autoCompleteType={ComponentUtils.PASSWORD_AUTOCOMPLETE_TYPE}
secureTextEntry
/>
</View>
)}
<CheckboxWithLabel
inputID="acceptedTerms"
LabelComponent={() => (
Expand Down Expand Up @@ -212,5 +219,8 @@ export default compose(
formData: {
key: ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM,
},
betas: {
key: ONYXKEYS.BETAS,
},
}),
)(DebitCardPage);
14 changes: 9 additions & 5 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class BasePaymentsPage extends React.Component {
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
}

makeDefaultPaymentMethod(password) {
makeDefaultPaymentMethod(password = '') {
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
const paymentMethods = PaymentUtils.formatPaymentMethods(
this.props.bankAccountList,
Expand Down Expand Up @@ -464,10 +464,14 @@ class BasePaymentsPage extends React.Component {
// InteractionManager fires after the currently running animation is completed.
// https://github.com/Expensify/App/issues/7768#issuecomment-1044879541
InteractionManager.runAfterInteractions(() => {
this.setState({
shouldShowPasswordPrompt: true,
passwordButtonText: this.props.translate('paymentsPage.setDefaultConfirmation'),
});
if (Permissions.canUsePasswordlessLogins(this.props.betas)) {
this.makeDefaultPaymentMethod();
} else {
this.setState({
shouldShowPasswordPrompt: true,
passwordButtonText: this.props.translate('paymentsPage.setDefaultConfirmation'),
});
}
});
}}
text={this.props.translate('paymentsPage.setDefaultConfirmation')}
Expand Down
38 changes: 26 additions & 12 deletions src/pages/settings/Profile/Contacts/AddSecondaryLoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import FixedFooter from '../../../../components/FixedFooter';
import TextInput from '../../../../components/TextInput';
import userPropTypes from '../../userPropTypes';
import * as LoginUtils from '../../../../libs/LoginUtils';
import Permissions from '../../../../libs/Permissions';

const propTypes = {
/* Onyx Props */
Expand All @@ -34,12 +35,16 @@ const propTypes = {
}),
}),

/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),

...withLocalizePropTypes,
};

const defaultProps = {
user: {},
route: {},
betas: [],
};

class AddSecondaryLoginPage extends Component {
Expand Down Expand Up @@ -85,7 +90,11 @@ class AddSecondaryLoginPage extends Component {
: this.state.login;

const validationMethod = this.formType === CONST.LOGIN_TYPE.PHONE ? Str.isValidPhone : Str.isValidEmail;
return !this.state.password || !validationMethod(login);
if (!validationMethod(login)) {
return false;
}

return !Permissions.canUsePasswordlessLogins(this.props.betas) && !this.state.password;
}

render() {
Expand Down Expand Up @@ -127,17 +136,19 @@ class AddSecondaryLoginPage extends Component {
returnKeyType="done"
/>
</View>
<View style={styles.mb6}>
<TextInput
label={this.props.translate('common.password')}
value={this.state.password}
onChangeText={password => this.setState({password})}
secureTextEntry
autoCompleteType="password"
textContentType="password"
onSubmitEditing={this.submitForm}
/>
</View>
{!Permissions.canUsePasswordlessLogins(this.props.betas) && (
<View style={styles.mb6}>
<TextInput
label={this.props.translate('common.password')}
value={this.state.password}
onChangeText={password => this.setState({password})}
secureTextEntry
autoCompleteType="password"
textContentType="password"
onSubmitEditing={this.submitForm}
/>
</View>
)}
{!_.isEmpty(this.props.user.error) && (
<Text style={styles.formError}>
{this.props.user.error}
Expand Down Expand Up @@ -168,5 +179,8 @@ export default compose(
user: {
key: ONYXKEYS.USER,
},
betas: {
key: ONYXKEYS.BETAS,
},
}),
)(AddSecondaryLoginPage);