From a8b73cf1a39ba31401e0d0fa840cb940abd7ed36 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 19 Mar 2024 01:19:38 +0700 Subject: [PATCH 1/3] fix annonymous user can open setting --- src/libs/actions/Link.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index ae95424f5776..05d95c200530 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -10,6 +10,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; +import * as Session from '@userActions/Session'; let isNetworkOffline = false; Onyx.connect({ @@ -102,6 +103,10 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { // If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) if (internalNewExpensifyPath && hasSameOrigin) { + if (Session.isAnonymousUser() && !Session.canAnonymousUserAccessRoute(internalNewExpensifyPath)) { + Session.signOutAndRedirectToSignIn() + return; + } Navigation.navigate(internalNewExpensifyPath as Route); return; } From b0083e99eeeaa00213dd415cd7b07b7e88fcc8e2 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 19 Mar 2024 01:32:02 +0700 Subject: [PATCH 2/3] fix lint --- src/libs/actions/Link.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 05d95c200530..0a80c0f37029 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -5,12 +5,12 @@ import asyncOpenURL from '@libs/asyncOpenURL'; import * as Environment from '@libs/Environment/Environment'; import Navigation from '@libs/Navigation/Navigation'; import * as Url from '@libs/Url'; +import * as Session from '@userActions/Session'; import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; -import * as Session from '@userActions/Session'; let isNetworkOffline = false; Onyx.connect({ @@ -104,7 +104,7 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) if (internalNewExpensifyPath && hasSameOrigin) { if (Session.isAnonymousUser() && !Session.canAnonymousUserAccessRoute(internalNewExpensifyPath)) { - Session.signOutAndRedirectToSignIn() + Session.signOutAndRedirectToSignIn(); return; } Navigation.navigate(internalNewExpensifyPath as Route); From 7c8242931129184cf6f6ca694b0d295c2dd40a4f Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 19 Mar 2024 01:32:58 +0700 Subject: [PATCH 3/3] fix lint --- src/libs/actions/Link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 0a80c0f37029..c83c946aed46 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -5,12 +5,12 @@ import asyncOpenURL from '@libs/asyncOpenURL'; import * as Environment from '@libs/Environment/Environment'; import Navigation from '@libs/Navigation/Navigation'; import * as Url from '@libs/Url'; -import * as Session from '@userActions/Session'; import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; +import * as Session from './Session'; let isNetworkOffline = false; Onyx.connect({