Skip to content

Commit

Permalink
Merge pull request #14854 from Expensify/beaman-passwordlessPolish
Browse files Browse the repository at this point in the history
User facing errors and messages on success / failure of magic code sending
  • Loading branch information
NikkiWines authored Feb 23, 2023
2 parents 53cabec + c6a4d42 commit cd2265f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export default {
enterAuthenticatorCode: 'Please enter your authenticator code',
twoFactorCode: 'Two factor code',
requiredWhen2FAEnabled: 'Required when 2FA is enabled',
codeSent: 'Magic code sent!',
error: {
pleaseFillMagicCode: 'Please enter your magic code',
incorrectMagicCode: 'Incorrect magic code.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export default {
enterAuthenticatorCode: 'Por favor ingresa su código de autenticador',
twoFactorCode: 'Autenticación de 2 factores',
requiredWhen2FAEnabled: 'Obligatorio cuando A2F está habilitado',
codeSent: '¡Código mágico enviado!',
error: {
pleaseFillMagicCode: 'Por favor, introduce el código mágico',
incorrectMagicCode: 'Código mágico incorrecto.',
Expand Down
35 changes: 35 additions & 0 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,40 @@ function resendValidationLink(login = credentials.login) {
API.write('RequestAccountValidationLink', {email: login}, {optimisticData, successData, failureData});
}

/**
* Request a new validate / magic code for user to sign in via passwordless flow
*
* @param {String} [login]
*/
function resendValidateCode(login = credentials.login) {
const optimisticData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: true,
errors: null,
message: null,
},
}];
const successData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: Localize.translateLocal('validateCodeForm.codeSent'),
},
}];
const failureData = [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: null,
},
}];
API.write('RequestNewValidateCode', {email: login}, {optimisticData, successData, failureData});
}

/**
* Checks the API to see if an account exists for the given login
*
Expand Down Expand Up @@ -539,6 +573,7 @@ export {
signOut,
signOutAndRedirectToSignIn,
resendValidationLink,
resendValidateCode,
resetPassword,
resendResetPassword,
clearSignInData,
Expand Down
5 changes: 3 additions & 2 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as SequentialQueue from '../Network/SequentialQueue';
import PusherUtils from '../PusherUtils';
import * as Report from './Report';
import * as ReportActionsUtils from '../ReportActionsUtils';
import * as Session from './Session';

let currentUserAccountID = '';
Onyx.connect({
Expand Down Expand Up @@ -95,8 +96,8 @@ function closeAccount(message) {
* @param {String} login
* @param {Boolean} isPasswordless - temporary param to trigger passwordless flow in backend
*/
function resendValidateCode(login, isPasswordless = false) {
DeprecatedAPI.ResendValidateCode({email: login, isPasswordless});
function resendValidateCode(login) {
Session.resendValidateCode(login);
}

/**
Expand Down

0 comments on commit cd2265f

Please sign in to comment.