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

Feat: Add Auth Content feature #2282

Conversation

ArthurTriis1
Copy link
Contributor

@ArthurTriis1 ArthurTriis1 commented Apr 8, 2024

What's the purpose of this pull request?

This PR aims to add the functionality of Auth Content, the first feature introduced as part of the Faststore B2B initiative. This feature allows the store to hide certain UI blocks and grant access only to authorized users. To learn more about Auth Content and the Faststore B2B initiative, please refer to the RFCs and Product Vision documentation.

B2B Faststore Product Vision
B2B Faststore RFC
Auth Content RFC

How it works?

useAuth and ProfileChallenge

To enable the auth content feature, the useAuth hook and the ProfileChallenge have been added to @faststore/core. The hook checks if the user is logged in and has a valid sales channel. The component renders the children only if the useAuth allows it.

hasOnlyDefaultSalesChannel

Faststore utilizes a default Sales Channel for various logic operations such as search and catalog access. To validate the Sales Channel without disrupting faststore logic, a new flag called "hasOnlyDefaultSalesChannel" has been introduced. As the name suggests, this flag indicates whether the logged-in user has a real Sales Channel or only the default Sales Channel. This flag is used by useAuth to control access to Auth Content.

Starters Deploy Preview

The Auth Content is be used in this Preview on b2bfaststoredev linked with this PR

How to test it?

The preview should hide the Hero content and only display it when a user with a Sales Channel logs in.

Screenshot 2024-04-08 at 23 45 20

References

B2B Faststore Product Vision
B2B Faststore RFC
Auth Content RFC
b2bfaststoredev
PR

Related Tasks

B2BTEAM-1591
B2BTEAM-1592

Copy link

vercel bot commented Apr 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
faststore-site ⬜️ Ignored (Inspect) Visit Preview Apr 9, 2024 2:08am

Copy link

codesandbox-ci bot commented Apr 8, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@ArthurTriis1 ArthurTriis1 force-pushed the feat/add-profile-challenge-component-and-hasOnlyDefaultSalesChannel branch from 72f542c to 2eb9339 Compare April 9, 2024 01:19
@ArthurTriis1 ArthurTriis1 force-pushed the feat/add-profile-challenge-component-and-hasOnlyDefaultSalesChannel branch from 2eb9339 to ec9dc67 Compare April 9, 2024 02:07
@ArthurTriis1 ArthurTriis1 changed the title Feat/add profile challenge component and has only default sales channel Feat: add profile challenge component and has only default sales channel Apr 9, 2024
@ArthurTriis1 ArthurTriis1 changed the title Feat: add profile challenge component and has only default sales channel Feat: adds profile challenge component and has only default sales channel Apr 9, 2024
@@ -29,7 +29,8 @@ module.exports = {
symbol: '$',
},
locale: 'en-US',
channel: '{"salesChannel":"1","regionId":""}',
channel:
'{"salesChannel":"1","regionId":"","hasOnlyDefaultSalesChannel":"true"}',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the validateSession throws an error, the default channel is used. Because of this, the 'hasOnlyDefaultSalesChannel': 'true' property was added in faststore.config

@ArthurTriis1 ArthurTriis1 self-assigned this Apr 9, 2024
@ArthurTriis1 ArthurTriis1 changed the title Feat: adds profile challenge component and has only default sales channel Feat: Add Auth Content feature Apr 9, 2024
@ArthurTriis1 ArthurTriis1 marked this pull request as ready for review April 9, 2024 19:29
@ArthurTriis1 ArthurTriis1 requested a review from a team as a code owner April 9, 2024 19:29
@ArthurTriis1 ArthurTriis1 requested review from gvc and lucasfp13 and removed request for a team April 9, 2024 19:29
@emersonlaurentino
Copy link
Member

suggestion: You created the auth SDK, but would be better if the SDK name was b2b because we want to create my-account natively on faststore and this auth that you created doesn't work in this case.

@ArthurTriis1
Copy link
Contributor Author

suggestion: You created the auth SDK, but would be better if the SDK name was b2b because we want to create my-account natively on faststore and this auth that you created doesn't work in this case.

Got it, we've decided not to use the B2B term because the idea is for this feature to be used to identify whether users are logged in or not, regardless of whether they are developing a B2B feature. The concept is to add features without necessarily having a "B2B" and "B2C" division.

It's interesting to know that the My Account feature is being brought to FastStore. Could you elaborate more on why this SDK wouldn't work in this case?

Copy link
Contributor

@lucasfp13 lucasfp13 left a comment

Choose a reason for hiding this comment

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

LGTM!

@emersonlaurentino emersonlaurentino merged commit 6db6dc7 into main Apr 18, 2024
7 checks passed
@emersonlaurentino emersonlaurentino deleted the feat/add-profile-challenge-component-and-hasOnlyDefaultSalesChannel branch April 18, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants