From fbcf0b6567cba1c626d13ffd9f7ca40c908bd8bc Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 23 Sep 2021 09:14:37 -1000 Subject: [PATCH 1/3] use correct api params --- src/libs/actions/App.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index c466fa7e4deb..397295e2242b 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -10,10 +10,12 @@ import Performance from '../Performance'; import Timing from './Timing'; let currentUserAccountID; +let currentUserEmail; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { currentUserAccountID = lodashGet(val, 'accountID', ''); + currentUserEmail = lodashGet(val, 'email', ''); }, }); @@ -49,7 +51,9 @@ function setLocale(locale) { */ function openSignedInLink(url = '') { API.GetShortLivedAuthToken().then((response) => { - Linking.openURL(`${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${response.authToken}&email=${encodeURIComponent(response.email)}`); + Linking.openURL( + `${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${response.shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`, + ); }); } From 204aef1524e001f72c4000fcc6e408a470d7c814 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 23 Sep 2021 09:23:13 -1000 Subject: [PATCH 2/3] clean up --- src/libs/actions/App.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 397295e2242b..fb79e02f6bdd 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -15,7 +15,7 @@ Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { currentUserAccountID = lodashGet(val, 'accountID', ''); - currentUserEmail = lodashGet(val, 'email', ''); + currentUserEmail = encodeURIComponent(lodashGet(val, 'email', '')); }, }); @@ -50,10 +50,8 @@ function setLocale(locale) { * @param {string} url relative URL starting with `/` to open in expensify.com */ function openSignedInLink(url = '') { - API.GetShortLivedAuthToken().then((response) => { - Linking.openURL( - `${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${response.shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`, - ); + API.GetShortLivedAuthToken().then(({shortLivedAuthToken}) => { + Linking.openURL(`${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${currentUserEmail}`); }); } From da910c32c6e7ca2defcb65b763fbf455cce339d8 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 23 Sep 2021 11:04:19 -1000 Subject: [PATCH 3/3] mvoe encodeURIComponent back to protect from tired stupid people who just want to drink beer --- src/libs/actions/App.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index fb79e02f6bdd..d0c4b0b71ed8 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -15,7 +15,7 @@ Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { currentUserAccountID = lodashGet(val, 'accountID', ''); - currentUserEmail = encodeURIComponent(lodashGet(val, 'email', '')); + currentUserEmail = lodashGet(val, 'email', ''); }, }); @@ -51,7 +51,7 @@ function setLocale(locale) { */ function openSignedInLink(url = '') { API.GetShortLivedAuthToken().then(({shortLivedAuthToken}) => { - Linking.openURL(`${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${currentUserEmail}`); + Linking.openURL(`${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`); }); }