-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[No QA] Remove unused parameter for short lived authToken #52501
Changes from 4 commits
be60f00
1ab2d64
79bc15c
6611508
3d8b706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,7 @@ | ||||||||||
import type {StackScreenProps} from '@react-navigation/stack'; | ||||||||||
import React, {useContext, useEffect} from 'react'; | ||||||||||
import {NativeModules} from 'react-native'; | ||||||||||
import {withOnyx} from 'react-native-onyx'; | ||||||||||
import type {OnyxEntry} from 'react-native-onyx'; | ||||||||||
import {useOnyx} from 'react-native-onyx'; | ||||||||||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||||||||||
import {InitialURLContext} from '@components/InitialURLContextProvider'; | ||||||||||
import * as SessionUtils from '@libs/SessionUtils'; | ||||||||||
|
@@ -14,24 +13,18 @@ import ONYXKEYS from '@src/ONYXKEYS'; | |||||||||
import ROUTES from '@src/ROUTES'; | ||||||||||
import type {Route} from '@src/ROUTES'; | ||||||||||
import type SCREENS from '@src/SCREENS'; | ||||||||||
import type {Session} from '@src/types/onyx'; | ||||||||||
|
||||||||||
type LogOutPreviousUserPageOnyxProps = { | ||||||||||
/** The data about the current session which will be set once the user is authenticated and we return to this component as an AuthScreen */ | ||||||||||
session: OnyxEntry<Session>; | ||||||||||
|
||||||||||
/** Is the account loading? */ | ||||||||||
isAccountLoading: boolean; | ||||||||||
}; | ||||||||||
|
||||||||||
type LogOutPreviousUserPageProps = LogOutPreviousUserPageOnyxProps & StackScreenProps<AuthScreensParamList, typeof SCREENS.TRANSITION_BETWEEN_APPS>; | ||||||||||
type LogOutPreviousUserPageProps = StackScreenProps<AuthScreensParamList, typeof SCREENS.TRANSITION_BETWEEN_APPS>; | ||||||||||
|
||||||||||
// This page is responsible for handling transitions from OldDot. Specifically, it logs the current user | ||||||||||
// out if the transition is for another user. | ||||||||||
// | ||||||||||
// This component should not do any other navigation as that handled in App.setUpPoliciesAndNavigate | ||||||||||
function LogOutPreviousUserPage({session, route, isAccountLoading}: LogOutPreviousUserPageProps) { | ||||||||||
function LogOutPreviousUserPage({route}: LogOutPreviousUserPageProps) { | ||||||||||
const {initialURL} = useContext(InitialURLContext); | ||||||||||
const [session] = useOnyx(ONYXKEYS.SESSION); | ||||||||||
const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT); | ||||||||||
const isAccountLoading = account?.isLoading; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, agree we should make it as before. Wdyt about this suggestion?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can remove the default value for account, but it doesn't need null coalesce because the logic is only doing a falsy check, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point |
||||||||||
|
||||||||||
useEffect(() => { | ||||||||||
const sessionEmail = session?.email; | ||||||||||
|
@@ -61,9 +54,8 @@ function LogOutPreviousUserPage({session, route, isAccountLoading}: LogOutPrevio | |||||||||
// On Enabling 2FA, authToken stored in Onyx becomes expired and hence we need to fetch new authToken | ||||||||||
const shouldForceLogin = route.params.shouldForceLogin === 'true'; | ||||||||||
if (shouldForceLogin) { | ||||||||||
const email = route.params.email ?? ''; | ||||||||||
const shortLivedAuthToken = route.params.shortLivedAuthToken ?? ''; | ||||||||||
SessionActions.signInWithShortLivedAuthToken(email, shortLivedAuthToken); | ||||||||||
SessionActions.signInWithShortLivedAuthToken(shortLivedAuthToken); | ||||||||||
} | ||||||||||
// We only want to run this effect once on mount (when the page first loads after transitioning from OldDot) | ||||||||||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||||||||||
|
@@ -93,12 +85,4 @@ function LogOutPreviousUserPage({session, route, isAccountLoading}: LogOutPrevio | |||||||||
|
||||||||||
LogOutPreviousUserPage.displayName = 'LogOutPreviousUserPage'; | ||||||||||
|
||||||||||
export default withOnyx<LogOutPreviousUserPageProps, LogOutPreviousUserPageOnyxProps>({ | ||||||||||
isAccountLoading: { | ||||||||||
key: ONYXKEYS.ACCOUNT, | ||||||||||
selector: (account) => account?.isLoading ?? false, | ||||||||||
}, | ||||||||||
session: { | ||||||||||
key: ONYXKEYS.SESSION, | ||||||||||
}, | ||||||||||
})(LogOutPreviousUserPage); | ||||||||||
export default LogOutPreviousUserPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, {useCallback, useState} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import WebView from 'react-native-webview'; | ||
import type {WebViewNativeEvent} from 'react-native-webview/lib/WebViewTypes'; | ||
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; | ||
|
@@ -13,9 +13,10 @@ import * as Session from '@userActions/Session'; | |
import CONFIG from '@src/CONFIG'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {SAMLSignInPageOnyxProps, SAMLSignInPageProps} from './types'; | ||
|
||
function SAMLSignInPage({credentials, account}: SAMLSignInPageProps) { | ||
function SAMLSignInPage() { | ||
const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a default for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we don't need that (explained in my other comment). The default object was just some copy/paste from other code that I will remove. |
||
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS); | ||
const samlLoginURL = `${CONFIG.EXPENSIFY.SAML_URL}?email=${credentials?.login}&referer=${CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER}&platform=${getPlatform()}`; | ||
const [showNavigation, shouldShowNavigation] = useState(true); | ||
|
||
|
@@ -34,7 +35,7 @@ function SAMLSignInPage({credentials, account}: SAMLSignInPageProps) { | |
const shortLivedAuthToken = searchParams.get('shortLivedAuthToken'); | ||
if (!account?.isLoading && credentials?.login && !!shortLivedAuthToken) { | ||
Log.info('SAMLSignInPage - Successfully received shortLivedAuthToken. Signing in...'); | ||
Session.signInWithShortLivedAuthToken(credentials.login, shortLivedAuthToken); | ||
Session.signInWithShortLivedAuthToken(shortLivedAuthToken); | ||
} | ||
|
||
// If the login attempt is unsuccessful, set the error message for the account and redirect to sign in page | ||
|
@@ -80,7 +81,4 @@ function SAMLSignInPage({credentials, account}: SAMLSignInPageProps) { | |
|
||
SAMLSignInPage.displayName = 'SAMLSignInPage'; | ||
|
||
export default withOnyx<SAMLSignInPageProps, SAMLSignInPageOnyxProps>({ | ||
credentials: {key: ONYXKEYS.CREDENTIALS}, | ||
account: {key: ONYXKEYS.ACCOUNT}, | ||
})(SAMLSignInPage); | ||
export default SAMLSignInPage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
isLoading
need to be null coalesced or defaulted in line 25?