From 41d4c411ef9425afd3f7bbc6a8f3bef8b3a3513f Mon Sep 17 00:00:00 2001 From: Sahan Jayawardana Date: Wed, 9 Sep 2020 06:18:28 +0530 Subject: [PATCH 1/2] Block content for anonymous users --- CHANGELOG.md | 4 ++++ react/BlockChallenge.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f62376a..464803b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Blocked content for anonymous users + ## [1.1.0] - 2020-08-13 ### Added diff --git a/react/BlockChallenge.tsx b/react/BlockChallenge.tsx index 30a35a5..5a9f8f2 100644 --- a/react/BlockChallenge.tsx +++ b/react/BlockChallenge.tsx @@ -29,7 +29,7 @@ const isProfileAllowed = (sessionResponse: SessionResponse | undefined) => { const isLoggedIn = (sessionResponse as Session).namespaces?.profile?.email - if (hasAccessToTradePolicy) { + if (isLoggedIn && hasAccessToTradePolicy) { return 'authorized' } From 63bec1644b83d33017ebf62d92c397630937f48b Mon Sep 17 00:00:00 2001 From: Sahan Jayawardana Date: Wed, 9 Sep 2020 06:28:26 +0530 Subject: [PATCH 2/2] Update README --- docs/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index a38c8e5..ceb6772 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,7 +8,13 @@ -The Auth Challenge app is an essential B2B feature responsible for checking iif a user is allowed to access the store's content. It helps define which components should be displayed for users that are allowed and users that are not. +The Auth Challenge app is an essential B2B feature responsible for checking if a user is allowed to access the store's content. It helps define which components should be displayed for users that are allowed and users that are not. + +## Example Use Case + +Add a condition to a TP that applies to your user. As an anonymous user, you should not see the real content. When you log in, and if and only if the condition you added above matches your profile, you should see the real content. + +Now remove the condition from the TP that applies to your user. Now as an anonymous user, you should not see the real content. When you login, you should see the real content. :information_source: This check is made according to the Condition Rule specified in the Trade Policy configuration, one of the steps needed to [**configure a B2B environment in VTEX IO**](https://vtex.io/docs/recipes/store/configuring-a-b2b-environment).