Skip to content
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
15 changes: 12 additions & 3 deletions src/libs/Authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ Onyx.connect({
},
});

function Authenticate(parameters: Parameters): Promise<Response> {
function Authenticate(parameters: Parameters): Promise<Response> | undefined {
const commandName = 'Authenticate';

requireParameters(['partnerName', 'partnerPassword', 'partnerUserID', 'partnerUserSecret'], parameters, commandName);
try {
requireParameters(['partnerName', 'partnerPassword', 'partnerUserID', 'partnerUserSecret'], parameters, commandName);
} catch (error) {
const errorMessage = (error as Error).message;
Log.hmmm('Redirecting to Sign In because we failed to reauthenticate', {
error: errorMessage,
});
redirectToSignIn(errorMessage);
return;
}

return post(commandName, {
// When authenticating for the first time, we pass useExpensifyLogin as true so we check
Expand Down Expand Up @@ -77,7 +86,7 @@ function reauthenticate(command = ''): Promise<void> | undefined {
partnerPassword: CONFIG.EXPENSIFY.PARTNER_PASSWORD,
partnerUserID: credentials?.autoGeneratedLogin,
partnerUserSecret: credentials?.autoGeneratedPassword,
}).then((response) => {
})?.then((response) => {
if (response.jsonCode === CONST.JSON_CODE.UNABLE_TO_RETRY) {
// When a fetch() fails due to a network issue and an error is thrown we won't log the user out. Most likely they
// have a spotty connection and will need to retry reauthenticate when they come back online. Error so it can be handled by the retry mechanism.
Expand Down
2 changes: 1 addition & 1 deletion src/libs/E2E/actions/e2eLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function (): Promise<boolean> {
// authenticate with a predefined user
console.debug('[E2E] Signing in…');
Authenticate(e2eUserCredentials)
.then((response) => {
?.then((response) => {
Onyx.merge(ONYXKEYS.SESSION, {
authToken: response.authToken,
creationDate: new Date().getTime(),
Expand Down