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

fix public room is not opened #37664

Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ function Expensify({
// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
Linking.getInitialURL().then((url) => {
setInitialUrl(url);
Report.openReportFromDeepLink(url ?? '', isAuthenticated);
Report.openReportFromDeepLink(url ?? '');
});

// Open chat report from a deep link (only mobile native)
Linking.addEventListener('url', (state) => {
Report.openReportFromDeepLink(state.url, isAuthenticated);
Report.openReportFromDeepLink(state.url);
});

return () => {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2214,10 +2214,10 @@ function toggleEmojiReaction(
addEmojiReaction(originalReportID, reportAction.reportActionID, emoji, skinTone);
}

function openReportFromDeepLink(url: string, isAuthenticated: boolean) {
function openReportFromDeepLink(url: string) {
const reportID = ReportUtils.getReportIDFromLink(url);

if (reportID && !isAuthenticated) {
if (reportID && !Session.isAuthenticated()) {
// Call the OpenReport command to check in the server if it's a public room. If so, we'll open it as an anonymous user
openReport(reportID, [], {}, '0', true);

Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ function hasStashedSession(): boolean {
return Boolean(stashedSession.authToken && stashedCredentials.autoGeneratedLogin && stashedCredentials.autoGeneratedLogin !== '');
}

/**
* Checks if the user is authenticated
*/
function isAuthenticated(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to hasAuthToken? I just don't want this method to be used improperly in the future to have people think that the user has actual permissions since this is really just "do they have an auth token" not "are they actually logged in"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stitesExpensify I changed the isAuthenticated to hasAuthToken

return !!session.authToken;
}

function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean, shouldStashSession?: boolean) {
Log.info('Redirecting to Sign In because signOut() was called');
hideContextMenu(false);
Expand Down Expand Up @@ -987,6 +994,7 @@ export {
validateTwoFactorAuth,
waitForUserSignIn,
canAccessRouteByAnonymousUser,
isAuthenticated,
signInWithSupportAuthToken,
isSupportAuthToken,
hasStashedSession,
Expand Down
Loading