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

Add supportal navigation #35410

Merged
merged 81 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
eb42af8
adding new properties
danieldoglas Jan 30, 2024
fe65f54
adding new logic for setting supportal token on public pages
danieldoglas Jan 30, 2024
ad993ab
adding logic in case you already have a session
danieldoglas Jan 30, 2024
f5acfa8
converting accountID to Number
danieldoglas Jan 30, 2024
9020de7
adding type of auth token to setSupportAuthToken
danieldoglas Jan 30, 2024
214590e
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 2, 2024
9343f30
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 6, 2024
28c567f
adding logs
danieldoglas Feb 6, 2024
0b896fd
fixing linter
danieldoglas Feb 6, 2024
a4a6ab1
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 6, 2024
72391f0
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 6, 2024
9b015a2
prettier
danieldoglas Feb 6, 2024
53bcd57
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 9, 2024
1553c7f
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 19, 2024
fde063a
fixes after merge
danieldoglas Feb 19, 2024
807a030
remove unused file
danieldoglas Feb 19, 2024
39c18b1
removing function setSupportAuthToken from network since it is alread…
danieldoglas Feb 19, 2024
0a79955
creating new parameters for using on API request
danieldoglas Feb 19, 2024
594693c
adding new method to call API with support token
danieldoglas Feb 19, 2024
a453d37
reusing function on signInWithShortLivedAuthToken
danieldoglas Feb 19, 2024
234df26
prettier
danieldoglas Feb 19, 2024
fccc71e
calling right method now
danieldoglas Feb 19, 2024
e8401c1
changing to right method on login page
danieldoglas Feb 19, 2024
51a84d3
prettier
danieldoglas Feb 20, 2024
fe97f39
changing method from getSupportAuthToken to isSupportAuthToken
danieldoglas Feb 20, 2024
f9b4116
simplifying token check
danieldoglas Feb 20, 2024
eaa9186
checking new method for support auth token
danieldoglas Feb 20, 2024
25032f1
updating comment
danieldoglas Feb 20, 2024
e7fd9c9
prettier
danieldoglas Feb 20, 2024
2bd4030
DRYing the types
danieldoglas Feb 23, 2024
2826307
adding token types to the const file
danieldoglas Feb 23, 2024
b00fe7b
changing method to isSupportTAuthToken to check the type from const
danieldoglas Feb 23, 2024
d7400f4
changing type to use valueOF const
danieldoglas Feb 23, 2024
8dc2f7e
changing usages to constant
danieldoglas Feb 23, 2024
61f0b39
updating usage to const
danieldoglas Feb 23, 2024
0956d29
separate set and clear support auth token
danieldoglas Feb 23, 2024
d136642
prettier
danieldoglas Feb 23, 2024
6eada6e
using finally data
danieldoglas Feb 23, 2024
286d4b8
addressing the last reference to supportal to use const
danieldoglas Feb 23, 2024
0e03fc5
changing inheritance to reference
danieldoglas Feb 23, 2024
533bff2
undo changes to ref
danieldoglas Feb 23, 2024
f1772a0
readding optional parameters and fixing routes to include central pan…
danieldoglas Feb 24, 2024
42e0295
removing explicity typing
danieldoglas Feb 24, 2024
53e8803
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Feb 28, 2024
aa31296
using new parameter of authtokentype
danieldoglas Feb 28, 2024
7bd9d4b
adding key for new translated item
danieldoglas Feb 29, 2024
1c8bcf1
exporting function to check if it's supportal
danieldoglas Feb 29, 2024
2a34120
changing text based on which type of token we're using
danieldoglas Feb 29, 2024
c052286
creating new keys for stashed sessiond ata
danieldoglas Feb 29, 2024
65ad0ab
mapping new keys
danieldoglas Feb 29, 2024
4258128
ignoring new keys when clearing the storage
danieldoglas Feb 29, 2024
226f6aa
adding logic to restore stashed login
danieldoglas Feb 29, 2024
e5b27b5
passing new parameters to stash login
danieldoglas Feb 29, 2024
4760635
using the whole session object so we can store it easily
danieldoglas Feb 29, 2024
0930f3c
logic should work
danieldoglas Feb 29, 2024
54db30b
adding one more check on the translation key
danieldoglas Feb 29, 2024
463fcb4
returning promise on signin redirect
danieldoglas Feb 29, 2024
caf1cf6
using promise to wait before setting the stashed data on session and …
danieldoglas Feb 29, 2024
bb51ff6
fixing message that should be shown
danieldoglas Feb 29, 2024
ddc3271
changin order on login page so we can check if it's supportal first
danieldoglas Feb 29, 2024
2df9180
passing parameter to store stashed login data
danieldoglas Feb 29, 2024
5a5d5bf
Removing stashed keys from clear storage
danieldoglas Mar 4, 2024
0240d99
removing transition from history on logout previous user page
danieldoglas Mar 4, 2024
907b2e4
removing transition from route on loginWithShortLivedAuthToken
danieldoglas Mar 4, 2024
25021a3
add additional logic to Session to confirm we're stashing credentials…
danieldoglas Mar 4, 2024
61ec184
Add propertitieson authscreen to guarantee we're executing the right …
danieldoglas Mar 4, 2024
ffb1d56
adding spanish translation
danieldoglas Mar 4, 2024
eed0aaf
prettier
danieldoglas Mar 4, 2024
e7b135f
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Mar 4, 2024
f06e890
linter
danieldoglas Mar 4, 2024
573bbb5
setting settion import as type
danieldoglas Mar 4, 2024
6d63941
refactor function for simplicity
danieldoglas Mar 4, 2024
a5f45b2
prettier again
danieldoglas Mar 4, 2024
114aee3
renaming property to clearer name
danieldoglas Mar 4, 2024
4af67a9
removing check if it's supportal call when enhancing the parameters
danieldoglas Mar 4, 2024
20b943d
setting parameters as optional
danieldoglas Mar 4, 2024
6fd8978
DRYing functions
danieldoglas Mar 4, 2024
992ed3a
DRYing functions
danieldoglas Mar 4, 2024
2931b5e
getting function back to network
danieldoglas Mar 4, 2024
9904a01
Merge branch 'main' into dsilva_addSupportalNavigation
danieldoglas Mar 4, 2024
205cb7f
fix comment after merge
danieldoglas Mar 4, 2024
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
2 changes: 2 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ type PublicScreensParamList = {
[NAVIGATORS.BOTTOM_TAB_NAVIGATOR]: NavigatorScreenParams<BottomTabNavigatorParamList>;
[SCREENS.TRANSITION_BETWEEN_APPS]: {
email?: string;
accountID?: number;
error?: string;
supportAuthToken?: string;
shortLivedAuthToken?: string;
shortLivedToken?: string;
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
exitTo?: Routes;
Expand Down
33 changes: 22 additions & 11 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,31 @@
*/
function signOut() {
Log.info('Flushing logs before signing out', true, {}, true);

// In case this is a supportal token, we won't have infinite sessions setup since the token will be
// short lived and we can just skip calling logout.
if (!isSupportalToken()) {

Check failure on line 91 in src/libs/actions/Session/index.ts

View workflow job for this annotation

GitHub Actions / lint

'isSupportalToken' was used before it was defined
mountiny marked this conversation as resolved.
Show resolved Hide resolved
const params: LogOutParams = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, you should just inline the params and rely on type inference

// Send current authToken because we will immediately clear it once triggering this command
authToken: NetworkStore.getAuthToken(),
partnerUserID: credentials?.autoGeneratedLogin ?? '',
partnerName: CONFIG.EXPENSIFY.PARTNER_NAME,
partnerPassword: CONFIG.EXPENSIFY.PARTNER_PASSWORD,
shouldRetry: false,
};

API.write(WRITE_COMMANDS.LOG_OUT, params);
}

const params: LogOutParams = {
// Send current authToken because we will immediately clear it once triggering this command
authToken: NetworkStore.getAuthToken(),
partnerUserID: credentials?.autoGeneratedLogin ?? '',
partnerName: CONFIG.EXPENSIFY.PARTNER_NAME,
partnerPassword: CONFIG.EXPENSIFY.PARTNER_PASSWORD,
shouldRetry: false,
};

API.write(WRITE_COMMANDS.LOG_OUT, params);
clearCache().then(() => {
Log.info('Cleared all cache data', true, {}, true);
});
Timing.clearData();

}

function isSupportalToken(): boolean {
return sessionAuthTokenType === 'supportal';
}

/**
Expand Down Expand Up @@ -540,11 +550,12 @@
function setSupportAuthToken(supportAuthToken: string, email: string, accountID: number) {
if (supportAuthToken) {
Onyx.merge(ONYXKEYS.SESSION, {
authTokenType: 'supportal',
authToken: '1',
supportAuthToken,
email,
accountID,
});
}).then(() => Log.info("[Supportal] Auth token set"));
} else {
Onyx.set(ONYXKEYS.SESSION, {});
}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/LogInWithShortLivedAuthTokenPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedA
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
const {email = '', shortLivedAuthToken = '', shortLivedToken = '', exitTo, error} = route?.params ?? {};
const {email = '', accountID = 0, supportAuthToken = '', shortLivedAuthToken = '', shortLivedToken = '', exitTo, error} = route?.params ?? {};

useEffect(() => {
// We have to check for both shortLivedAuthToken and shortLivedToken, as the old mobile app uses shortLivedToken, and is not being actively updated.
Expand All @@ -44,6 +44,11 @@ function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedA
return;
}

if (!account?.isLoading && accountID && supportAuthToken) {
Session.setSupportAuthToken(supportAuthToken, email, Number(accountID));
return;
}

// If an error is returned as part of the route, ensure we set it in the onyxData for the account
if (error) {
Session.setAccountError(error);
Expand Down
8 changes: 8 additions & 0 deletions src/pages/LogOutPreviousUserPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ function LogOutPreviousUserPage(props) {
const shortLivedAuthToken = lodashGet(props, 'route.params.shortLivedAuthToken', '');
Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken);
}

const isSupportalLogin = lodashGet(props, 'route.params.supportAuthToken', '') !== '';
if (isSupportalLogin) {
const email = lodashGet(props, 'route.params.email', '');
const supportAuthToken = lodashGet(props, 'route.params.supportAuthToken', '');
const accountID = lodashGet(props, 'route.params.accountID', 0);
Session.setSupportAuthToken(supportAuthToken, email, Number(accountID));
}
});

// We only want to run this effect once on mount (when the page first loads after transitioning from OldDot)
Expand Down
Loading