Skip to content

Commit

Permalink
New command to validate a secondary login
Browse files Browse the repository at this point in the history
  • Loading branch information
Beamanator committed Feb 22, 2023
1 parent 32f443c commit 748f3db
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default {
youAppearToBeOffline: 'You appear to be offline.',
thisFeatureRequiresInternet: 'This feature requires an active internet connection to be used.',
areYouSure: 'Are you sure?',
verify: 'Verify',
yesContinue: 'Yes, continue',
zipCodeExample: 'e.g. 12345, 12345-1234, 12345 1234',
websiteExample: 'e.g. https://www.expensify.com',
Expand Down Expand Up @@ -354,6 +355,7 @@ export default {
resendMagicCode: 'Resend magic code',
genericFailureMessages: {
requestContactMethodValidateCode: 'Failed to send a new magic code. Please wait a bit and try again.',
validateSecondaryLogin: 'Failed to validate contact method with given magic code. Please request a new code and try again.',
},
},
pronouns: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default {
youAppearToBeOffline: 'Parece que estás desconectado.',
thisFeatureRequiresInternet: 'Esta función requiere una conexión a Internet activa para ser utilizada.',
areYouSure: '¿Estás seguro?',
verify: '',
yesContinue: '',
zipCodeExample: 'p. ej. 12345, 12345-1234, 12345 1234',
websiteExample: 'p. ej. https://www.expensify.com',
Expand Down Expand Up @@ -354,6 +355,7 @@ export default {
resendMagicCode: '',
genericFailureMessages: {
requestContactMethodValidateCode: '',
validateSecondaryLogin: '',
},
},
pronouns: {
Expand Down
53 changes: 53 additions & 0 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,58 @@ function validateLogin(accountID, validateCode) {
Navigation.navigate(ROUTES.HOME);
}

/**
* Validates a secondary login / contact method
*
* @param {String} contactMethod - The contact method the user is trying to verify
* @param {String} validateCode
*/
function validateSecondaryLogin(contactMethod, validateCode) {
const optimisticData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.LOGIN_LIST,
value: {
[contactMethod]: {
errorFields: {
validateLogin: null,
},

This comment has been minimized.

Copy link
@c3024

c3024 Dec 28, 2023

Contributor

There was a case missed here in which two errors appear at the same time.
This happens when
First, user clicks on get magic code many times so an error for that appears.
Then, the user enters an incorrect code. The error for incorrect code appears then.

pendingFields: {
validateLogin: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
}];
const successData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.LOGIN_LIST,
value: {
[contactMethod]: {
pendingFields: {
validateLogin: null,
},
},
},
}];
const failureData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.LOGIN_LIST,
value: {
[contactMethod]: {
errorFields: {
validateLogin: {
[DateUtils.getMicroseconds()]: Localize.translateLocal('contacts.genericFailureMessages.validateSecondaryLogin'),
},
},
pendingFields: {
validateLogin: null,
},
},
},
}];

API.write('ValidateSecondaryLogin', {validateCode}, {optimisticData, successData, failureData});
}

/**
* Checks the blockedFromConcierge object to see if it has an expiresAt key,
* and if so whether the expiresAt date of a user's ban is before right now
Expand Down Expand Up @@ -598,6 +650,7 @@ export {
deleteContactMethod,
clearContactMethodErrors,
validateLogin,
validateSecondaryLogin,
isBlockedFromConcierge,
subscribeToUserEvents,
updatePreferredSkinTone,
Expand Down

0 comments on commit 748f3db

Please sign in to comment.