diff --git a/src/CONST.ts b/src/CONST.ts index 8d4eaac44a38..ba3794659d59 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3332,6 +3332,10 @@ const CONST = { SESSION_STORAGE_KEYS: { INITIAL_URL: 'INITIAL_URL', }, + + AUTH_TOKEN_TYPE: { + ANONYMOUS: 'anonymousAccount', + }, } as const; type Country = keyof typeof CONST.ALL_COUNTRIES; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a814c91ea8b2..f64123aceaf8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -438,7 +438,7 @@ Onyx.connect({ currentUserEmail = value.email; currentUserAccountID = value.accountID; - isAnonymousUser = value.authTokenType === 'anonymousAccount'; + isAnonymousUser = value.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; currentUserPrivateDomain = isEmailPublicDomain(currentUserEmail ?? '') ? '' : Str.extractEmailDomain(currentUserEmail ?? ''); }, }); diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 013d86049150..76f335a3bec0 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -107,7 +107,7 @@ function signOut() { * Checks if the account is an anonymous account. */ function isAnonymousUser(): boolean { - return sessionAuthTokenType === 'anonymousAccount'; + return sessionAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; } function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean) { diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index cd625a667a7f..ed414de134f4 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -140,7 +140,7 @@ function ReportActionsView(props) { }, [props.network, isReportFullyVisible]); useEffect(() => { - const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType; + const wasLoginChangedDetected = prevAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS && !props.session.authTokenType; if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) { if (isReportFullyVisible) { openReportIfNecessary(); diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js index 7372d3fb4854..3b9f8f03c320 100644 --- a/src/pages/home/report/ReportFooter.js +++ b/src/pages/home/report/ReportFooter.js @@ -67,7 +67,7 @@ function ReportFooter(props) { const {isOffline} = useNetwork(); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); - const isAnonymousUser = props.session.authTokenType === 'anonymousAccount'; + const isAnonymousUser = props.session.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; const hideComposer = !ReportUtils.canUserPerformWriteAction(props.report); diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 741074fa952b..e71ee6e9a988 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import Navigation from '@libs/Navigation/Navigation'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; import type {Session} from '@src/types/onyx'; @@ -22,7 +23,7 @@ function SignInModal({session}: SignInModalProps) { const StyleUtils = useStyleUtils(); useEffect(() => { - const isAnonymousUser = session?.authTokenType === 'anonymousAccount'; + const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; if (!isAnonymousUser) { // Signing in RHP is only for anonymous users Navigation.isNavigationReady().then(() => Navigation.dismissModal());