@faststore/core 3.57.0 → 3.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +21 -21
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/6011.js +2 -2
- package/.next/server/chunks/7947.js +1 -0
- package/.next/server/chunks/9563.js +1 -1
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/account/403.js +1 -1
- package/.next/server/pages/account/403.js.nft.json +1 -1
- package/.next/server/pages/account/404.js +1 -1
- package/.next/server/pages/account/404.js.nft.json +1 -1
- package/.next/server/pages/account/[...unknown].js.nft.json +1 -1
- package/.next/server/pages/account/orders/[id].js +1 -1
- package/.next/server/pages/account/orders/[id].js.nft.json +1 -1
- package/.next/server/pages/account/orders.js +1 -1
- package/.next/server/pages/account/orders.js.nft.json +1 -1
- package/.next/server/pages/account/profile.js +1 -1
- package/.next/server/pages/account/profile.js.nft.json +1 -1
- package/.next/server/pages/account/security.js +1 -1
- package/.next/server/pages/account/security.js.nft.json +1 -1
- package/.next/server/pages/account/user-details.js +1 -1
- package/.next/server/pages/account/user-details.js.nft.json +1 -1
- package/.next/server/pages/account.js +1 -1
- package/.next/server/pages/account.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/api/health/live.js.nft.json +1 -1
- package/.next/server/pages/api/health/ready.js.nft.json +1 -1
- package/.next/server/pages/api/preview.js.nft.json +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/{webpack-39ca6907398b1ba6.js → webpack-442c329509c9052f.js} +1 -1
- package/.next/trace +128 -128
- package/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-test.log +5 -5
- package/@generated/gql.ts +8 -0
- package/@generated/graphql.ts +20 -0
- package/@generated/persisted-documents.json +1 -0
- package/@generated/schema.graphql +7 -0
- package/CHANGELOG.md +6 -0
- package/package.json +3 -3
- package/src/experimental/myAccountSeverSideProps.ts +11 -1
- package/src/pages/account/403.tsx +11 -1
- package/src/pages/account/404.tsx +11 -1
- package/src/pages/account/[...unknown].tsx +0 -2
- package/src/pages/account/index.tsx +15 -2
- package/src/pages/account/orders/[id].tsx +11 -1
- package/src/pages/account/orders/index.tsx +11 -1
- package/src/pages/account/profile.tsx +11 -1
- package/src/pages/account/security.tsx +11 -1
- package/src/pages/account/user-details.tsx +11 -1
- package/src/sdk/account/validateUser.ts +32 -0
- package/test/server/index.test.ts +1 -0
- /package/.next/static/{mRyzU18kzIS5letQIEfoD → xEUAx3sARWz-pqtOPFb08}/_buildManifest.js +0 -0
- /package/.next/static/{mRyzU18kzIS5letQIEfoD → xEUAx3sARWz-pqtOPFb08}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.
|
|
2
|
+
> @faststore/core@3.57.0 prebuild /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> na run partytown && na run generate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @faststore/core@3.
|
|
6
|
+
> @faststore/core@3.57.0 partytown /home/runner/work/faststore/faststore/packages/core
|
|
7
7
|
> partytown copylib ./public/~partytown
|
|
8
8
|
|
|
9
9
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
10
10
|
|
|
11
|
-
> @faststore/core@3.
|
|
11
|
+
> @faststore/core@3.57.0 generate /home/runner/work/faststore/faststore/packages/core
|
|
12
12
|
> na run generate:schema && na run generate:codegen && na run format:generated
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
> @faststore/core@3.
|
|
15
|
+
> @faststore/core@3.57.0 generate:schema /home/runner/work/faststore/faststore/packages/core
|
|
16
16
|
> tsx src/server/generator/generateGraphQLSchemaFile.ts
|
|
17
17
|
|
|
18
18
|
Schema GraphQL file generated successfully
|
|
19
19
|
|
|
20
|
-
> @faststore/core@3.
|
|
20
|
+
> @faststore/core@3.57.0 generate:codegen /home/runner/work/faststore/faststore/packages/core
|
|
21
21
|
> graphql-codegen
|
|
22
22
|
|
|
23
23
|
[STARTED] Parse Configuration
|
|
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
|
|
|
37
37
|
[CLI] Loading Documents
|
|
38
38
|
[CLI] Generating output
|
|
39
39
|
|
|
40
|
-
> @faststore/core@3.
|
|
40
|
+
> @faststore/core@3.57.0 format:generated /home/runner/work/faststore/faststore/packages/core
|
|
41
41
|
> prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
> @faststore/core@3.
|
|
44
|
+
> @faststore/core@3.57.0 build /home/runner/work/faststore/faststore/packages/core
|
|
45
45
|
> next build
|
|
46
46
|
|
|
47
47
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
@@ -59,8 +59,8 @@ https://nextjs.org/telemetry
|
|
|
59
59
|
Collecting page data ...
|
|
60
60
|
Generating static pages (0/6) ...
|
|
61
61
|
|
|
62
62
|
Generating static pages (1/6)
|
|
63
|
-
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
64
63
|
|
|
65
64
|
Generating static pages (2/6)
|
|
65
|
+
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
66
66
|
|
|
67
67
|
Generating static pages (4/6)
|
|
68
68
|
|
|
69
69
|
✓ Generating static pages (6/6)
|
|
70
70
|
Finalizing page optimization ...
|
|
@@ -101,7 +101,7 @@ Route (pages) Size First Load JS
|
|
|
101
101
|
├ chunks/framework-807b0f81cbc129f0.js 45.4 kB
|
|
102
102
|
├ chunks/main-f658704b53a96ab1.js 33.1 kB
|
|
103
103
|
├ chunks/pages/_app-eb6edb0ba4b4be67.js 16.3 kB
|
|
104
|
-
├ chunks/webpack-
|
|
104
|
+
├ chunks/webpack-442c329509c9052f.js 3.7 kB
|
|
105
105
|
└ css/0a57ee6c7a57788c.css 3.49 kB
|
|
106
106
|
|
|
107
107
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.
|
|
2
|
+
> @faststore/core@3.57.0 test /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> jest
|
|
4
4
|
|
|
5
|
-
PASS test/server/cms/global.test.ts (24.
|
|
6
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
5
|
+
PASS test/server/cms/global.test.ts (24.83 s)
|
|
6
|
+
PASS test/utils/multipleTemplates.test.ts (24.884 s)
|
|
7
7
|
PASS test/server/cms/index.test.ts
|
|
8
|
-
PASS test/server/index.test.ts (
|
|
8
|
+
PASS test/server/index.test.ts (30.148 s)
|
|
9
9
|
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
|
|
10
10
|
|
|
11
11
|
Test Suites: 4 passed, 4 total
|
|
12
12
|
Tests: 22 passed, 22 total
|
|
13
13
|
Snapshots: 0 total
|
|
14
|
-
Time:
|
|
14
|
+
Time: 31.704 s
|
|
15
15
|
Ran all test suites.
|
package/@generated/gql.ts
CHANGED
|
@@ -56,6 +56,8 @@ const documents = {
|
|
|
56
56
|
types.ServerUserDetailsQueryDocument,
|
|
57
57
|
'\n mutation CancelOrderMutation($data: IUserOrderCancel!) {\n cancelOrder(data: $data) {\n data\n }\n }\n':
|
|
58
58
|
types.CancelOrderMutationDocument,
|
|
59
|
+
'\n query ValidateUser {\n validateUser {\n isValid\n }\n }\n':
|
|
60
|
+
types.ValidateUserDocument,
|
|
59
61
|
'\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n shouldSplitItem\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n':
|
|
60
62
|
types.ValidateCartMutationDocument,
|
|
61
63
|
'\n mutation SubscribeToNewsletter($data: IPersonNewsletter!) {\n subscribeToNewsletter(data: $data) {\n id\n }\n }\n':
|
|
@@ -216,6 +218,12 @@ export function gql(
|
|
|
216
218
|
export function gql(
|
|
217
219
|
source: '\n mutation CancelOrderMutation($data: IUserOrderCancel!) {\n cancelOrder(data: $data) {\n data\n }\n }\n'
|
|
218
220
|
): typeof import('./graphql').CancelOrderMutationDocument
|
|
221
|
+
/**
|
|
222
|
+
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
223
|
+
*/
|
|
224
|
+
export function gql(
|
|
225
|
+
source: '\n query ValidateUser {\n validateUser {\n isValid\n }\n }\n'
|
|
226
|
+
): typeof import('./graphql').ValidateUserDocument
|
|
219
227
|
/**
|
|
220
228
|
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
221
229
|
*/
|
package/@generated/graphql.ts
CHANGED
|
@@ -561,6 +561,8 @@ export type Query = {
|
|
|
561
561
|
shipping: Maybe<ShippingData>
|
|
562
562
|
/** Returns information about the Details of an User Order. */
|
|
563
563
|
userOrder: Maybe<UserOrderResult>
|
|
564
|
+
/** Returns information about the user validation. */
|
|
565
|
+
validateUser: Maybe<ValidateUserData>
|
|
564
566
|
}
|
|
565
567
|
|
|
566
568
|
export type QueryAllCollectionsArgs = {
|
|
@@ -1997,6 +1999,11 @@ export type UserOrderTransactions = {
|
|
|
1997
1999
|
transactionId: Maybe<Scalars['String']['output']>
|
|
1998
2000
|
}
|
|
1999
2001
|
|
|
2002
|
+
export type ValidateUserData = {
|
|
2003
|
+
/** Indicates if the user is valid. */
|
|
2004
|
+
isValid: Scalars['Boolean']['output']
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2000
2007
|
export type ProductSummary_ProductFragment = {
|
|
2001
2008
|
slug: string
|
|
2002
2009
|
sku: string
|
|
@@ -2459,6 +2466,10 @@ export type CancelOrderMutationMutation = {
|
|
|
2459
2466
|
cancelOrder: { data: string | null } | null
|
|
2460
2467
|
}
|
|
2461
2468
|
|
|
2469
|
+
export type ValidateUserQueryVariables = Exact<{ [key: string]: never }>
|
|
2470
|
+
|
|
2471
|
+
export type ValidateUserQuery = { validateUser: { isValid: boolean } | null }
|
|
2472
|
+
|
|
2462
2473
|
export type ValidateCartMutationMutationVariables = Exact<{
|
|
2463
2474
|
cart: IStoreCart
|
|
2464
2475
|
session: IStoreSession
|
|
@@ -3546,6 +3557,15 @@ export const CancelOrderMutationDocument = {
|
|
|
3546
3557
|
CancelOrderMutationMutation,
|
|
3547
3558
|
CancelOrderMutationMutationVariables
|
|
3548
3559
|
>
|
|
3560
|
+
export const ValidateUserDocument = {
|
|
3561
|
+
__meta__: {
|
|
3562
|
+
operationName: 'ValidateUser',
|
|
3563
|
+
operationHash: '32f99c73c3de958b64d6bece1afe800469f54548',
|
|
3564
|
+
},
|
|
3565
|
+
} as unknown as TypedDocumentString<
|
|
3566
|
+
ValidateUserQuery,
|
|
3567
|
+
ValidateUserQueryVariables
|
|
3568
|
+
>
|
|
3549
3569
|
export const ValidateCartMutationDocument = {
|
|
3550
3570
|
__meta__: {
|
|
3551
3571
|
operationName: 'ValidateCartMutation',
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"9f24767f16e6e05c168336701a6c6c7b6b5dc1c6": "query ServerSecurityQuery { accountName }",
|
|
9
9
|
"92d9db34aa133d60d474c6d4cdcdd2fc19041a5e": "query ServerUserDetailsQuery { accountName }",
|
|
10
10
|
"e2b06da6840614d3c72768e56579b9d3b8e80802": "mutation CancelOrderMutation($data: IUserOrderCancel!) { cancelOrder(data: $data) { data } }",
|
|
11
|
+
"32f99c73c3de958b64d6bece1afe800469f54548": "query ValidateUser { validateUser { isValid } }",
|
|
11
12
|
"c2b3f8bff73ebf6ac79d758c66cabbc21ba9fcc0": "fragment CartItem on StoreOffer { itemOffered { ...CartProductItem } listPrice listPriceWithTaxes price priceWithTaxes quantity seller { identifier } } fragment CartMessage on StoreCartMessage { status text } fragment CartProductItem on StoreProduct { additionalProperty { name propertyID value valueReference } brand { name } gtin image { alternateName url } isVariantOf { name productGroupID skuVariants { activeVariations availableVariations slugsMap } } name sku unitMultiplier } mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) { validateCart(cart: $cart, session: $session) { messages { ...CartMessage } order { acceptedOffer { ...CartItem } orderNumber shouldSplitItem } } }",
|
|
12
13
|
"feb7005103a859e2bc8cf2360d568806fd88deba": "mutation SubscribeToNewsletter($data: IPersonNewsletter!) { subscribeToNewsletter(data: $data) { id } }",
|
|
13
14
|
"dc912e7272e3d9f5ced206837df87f544d39d0a5": "query ClientProductCountQuery($term: String) { productCount(term: $term) { total } }",
|
|
@@ -710,6 +710,13 @@ type Query {
|
|
|
710
710
|
): UserOrderListMinimalResult @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
|
|
711
711
|
"""Returns the account name of the current user or the B2B contract name if applicable."""
|
|
712
712
|
accountName: String @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
|
|
713
|
+
"""Returns information about the user validation."""
|
|
714
|
+
validateUser: ValidateUserData @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
type ValidateUserData {
|
|
718
|
+
"""Indicates if the user is valid."""
|
|
719
|
+
isValid: Boolean!
|
|
713
720
|
}
|
|
714
721
|
|
|
715
722
|
"""
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.58.0](https://github.com/vtex/faststore/compare/v3.57.0...v3.58.0) (2025-06-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add user validation query and implement access control in MyAccount ([#2899](https://github.com/vtex/faststore/issues/2899)) ([48978bf](https://github.com/vtex/faststore/commit/48978bf90e486b5eaa38ee230e7d8f9a269fb910))
|
|
11
|
+
|
|
6
12
|
# [3.57.0](https://github.com/vtex/faststore/compare/v3.56.3...v3.57.0) (2025-06-20)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.58.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@envelop/graphql-jit": "^8.0.3",
|
|
45
45
|
"@envelop/parser-cache": "^6.0.2",
|
|
46
46
|
"@envelop/validation-cache": "^6.0.2",
|
|
47
|
-
"@faststore/api": "^3.
|
|
47
|
+
"@faststore/api": "^3.58.0",
|
|
48
48
|
"@faststore/graphql-utils": "^3.56.1",
|
|
49
49
|
"@faststore/lighthouse": "^3.56.1",
|
|
50
50
|
"@faststore/sdk": "^3.56.1",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"ts-jest": "29.1.1",
|
|
106
106
|
"typescript": "5.3.2"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "714b4b286130446f08511010d3cb14309ed9a9c7"
|
|
109
109
|
}
|
|
@@ -14,6 +14,7 @@ import { execute } from 'src/server'
|
|
|
14
14
|
|
|
15
15
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
16
16
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
17
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
17
18
|
|
|
18
19
|
export type MyAccountProps = {
|
|
19
20
|
globalSections: GlobalSectionsData
|
|
@@ -31,7 +32,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
31
32
|
Record<string, string>,
|
|
32
33
|
Locator
|
|
33
34
|
> = async (context) => {
|
|
34
|
-
|
|
35
|
+
const isValid = await validateUser(context)
|
|
36
|
+
|
|
37
|
+
if (!isValid) {
|
|
38
|
+
return {
|
|
39
|
+
redirect: {
|
|
40
|
+
destination: '/login',
|
|
41
|
+
permanent: false,
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
}
|
|
35
45
|
|
|
36
46
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
37
47
|
query: context.query,
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
ServerAccountPageQueryQuery,
|
|
24
24
|
ServerAccountPageQueryQueryVariables,
|
|
25
25
|
} from '@generated/graphql'
|
|
26
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
26
27
|
|
|
27
28
|
/* A list of components that can be used in the CMS. */
|
|
28
29
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -71,7 +72,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
71
72
|
Record<string, string>,
|
|
72
73
|
Locator
|
|
73
74
|
> = async (context) => {
|
|
74
|
-
|
|
75
|
+
const isValid = await validateUser(context)
|
|
76
|
+
|
|
77
|
+
if (!isValid) {
|
|
78
|
+
return {
|
|
79
|
+
redirect: {
|
|
80
|
+
destination: '/login',
|
|
81
|
+
permanent: false,
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
}
|
|
75
85
|
|
|
76
86
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
77
87
|
query: context.query,
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
ServerAccountPageQueryQuery,
|
|
25
25
|
ServerAccountPageQueryQueryVariables,
|
|
26
26
|
} from '@generated/graphql'
|
|
27
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
27
28
|
|
|
28
29
|
/* A list of components that can be used in the CMS. */
|
|
29
30
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -67,7 +68,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
67
68
|
Record<string, string>,
|
|
68
69
|
Locator
|
|
69
70
|
> = async (context) => {
|
|
70
|
-
|
|
71
|
+
const isValid = await validateUser(context)
|
|
72
|
+
|
|
73
|
+
if (!isValid) {
|
|
74
|
+
return {
|
|
75
|
+
redirect: {
|
|
76
|
+
destination: '/login',
|
|
77
|
+
permanent: false,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
71
81
|
|
|
72
82
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
73
83
|
query: context.query,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
1
2
|
import type { GetServerSideProps, NextPage } from 'next'
|
|
2
3
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
3
4
|
|
|
@@ -5,8 +6,20 @@ const MyAccountRedirectPage: NextPage = () => {
|
|
|
5
6
|
return null
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export const getServerSideProps: GetServerSideProps = async ({
|
|
9
|
-
|
|
9
|
+
export const getServerSideProps: GetServerSideProps = async ({
|
|
10
|
+
query,
|
|
11
|
+
req,
|
|
12
|
+
}) => {
|
|
13
|
+
const isValid = await validateUser({ query, req } as any)
|
|
14
|
+
|
|
15
|
+
if (!isValid) {
|
|
16
|
+
return {
|
|
17
|
+
redirect: {
|
|
18
|
+
destination: '/login',
|
|
19
|
+
permanent: false,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
|
|
11
24
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
12
25
|
query,
|
|
@@ -8,6 +8,7 @@ import RenderSections from 'src/components/cms/RenderSections'
|
|
|
8
8
|
import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
|
|
9
9
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
10
10
|
import type { MyAccountProps } from 'src/experimental/myAccountSeverSideProps'
|
|
11
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
11
12
|
|
|
12
13
|
import { gql } from '@generated'
|
|
13
14
|
import type {
|
|
@@ -204,7 +205,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
204
205
|
Record<string, string>,
|
|
205
206
|
Locator
|
|
206
207
|
> = async (context) => {
|
|
207
|
-
|
|
208
|
+
const isValid = await validateUser(context)
|
|
209
|
+
|
|
210
|
+
if (!isValid) {
|
|
211
|
+
return {
|
|
212
|
+
redirect: {
|
|
213
|
+
destination: '/login',
|
|
214
|
+
permanent: false,
|
|
215
|
+
},
|
|
216
|
+
}
|
|
217
|
+
}
|
|
208
218
|
|
|
209
219
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
210
220
|
query: context.query,
|
|
@@ -24,6 +24,7 @@ import { groupOrderStatusByLabel } from 'src/utils/userOrderStatus'
|
|
|
24
24
|
|
|
25
25
|
import { MyAccountListOrders } from 'src/components/account/orders/MyAccountListOrders'
|
|
26
26
|
import { extractStatusFromError } from 'src/utils/utilities'
|
|
27
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
27
28
|
|
|
28
29
|
/* A list of components that can be used in the CMS. */
|
|
29
30
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -118,7 +119,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
118
119
|
Record<string, string>,
|
|
119
120
|
Locator
|
|
120
121
|
> = async (context) => {
|
|
121
|
-
|
|
122
|
+
const isValid = await validateUser(context)
|
|
123
|
+
|
|
124
|
+
if (!isValid) {
|
|
125
|
+
return {
|
|
126
|
+
redirect: {
|
|
127
|
+
destination: '/login',
|
|
128
|
+
permanent: false,
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
}
|
|
122
132
|
|
|
123
133
|
const { previewData } = context
|
|
124
134
|
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
ServerProfileQueryQuery,
|
|
24
24
|
ServerProfileQueryQueryVariables,
|
|
25
25
|
} from '@generated/graphql'
|
|
26
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
26
27
|
|
|
27
28
|
/* A list of components that can be used in the CMS. */
|
|
28
29
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -63,7 +64,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
63
64
|
Record<string, string>,
|
|
64
65
|
Locator
|
|
65
66
|
> = async (context) => {
|
|
66
|
-
|
|
67
|
+
const isValid = await validateUser(context)
|
|
68
|
+
|
|
69
|
+
if (!isValid) {
|
|
70
|
+
return {
|
|
71
|
+
redirect: {
|
|
72
|
+
destination: '/login',
|
|
73
|
+
permanent: false,
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
67
77
|
|
|
68
78
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
69
79
|
query: context.query,
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
ServerSecurityQueryQuery,
|
|
25
25
|
ServerSecurityQueryQueryVariables,
|
|
26
26
|
} from '@generated/graphql'
|
|
27
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
27
28
|
|
|
28
29
|
/* A list of components that can be used in the CMS. */
|
|
29
30
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -68,7 +69,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
68
69
|
Record<string, string>,
|
|
69
70
|
Locator
|
|
70
71
|
> = async (context) => {
|
|
71
|
-
|
|
72
|
+
const isValid = await validateUser(context)
|
|
73
|
+
|
|
74
|
+
if (!isValid) {
|
|
75
|
+
return {
|
|
76
|
+
redirect: {
|
|
77
|
+
destination: '/login',
|
|
78
|
+
permanent: false,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
72
82
|
|
|
73
83
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
74
84
|
query: context.query,
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
ServerUserDetailsQueryQuery,
|
|
25
25
|
ServerUserDetailsQueryQueryVariables,
|
|
26
26
|
} from '@generated/graphql'
|
|
27
|
+
import { validateUser } from 'src/sdk/account/validateUser'
|
|
27
28
|
|
|
28
29
|
/* A list of components that can be used in the CMS. */
|
|
29
30
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -64,7 +65,16 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
64
65
|
Record<string, string>,
|
|
65
66
|
Locator
|
|
66
67
|
> = async (context) => {
|
|
67
|
-
|
|
68
|
+
const isValid = await validateUser(context)
|
|
69
|
+
|
|
70
|
+
if (!isValid) {
|
|
71
|
+
return {
|
|
72
|
+
redirect: {
|
|
73
|
+
destination: '/login',
|
|
74
|
+
permanent: false,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|
|
68
78
|
|
|
69
79
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
70
80
|
query: context.query,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { gql } from '@generated/gql'
|
|
2
|
+
import type {
|
|
3
|
+
ValidateUserQuery,
|
|
4
|
+
ValidateUserQueryVariables,
|
|
5
|
+
} from '@generated/graphql'
|
|
6
|
+
import type { GetServerSidePropsContext } from 'next'
|
|
7
|
+
import { execute } from 'src/server'
|
|
8
|
+
|
|
9
|
+
const query = gql(`
|
|
10
|
+
query ValidateUser {
|
|
11
|
+
validateUser {
|
|
12
|
+
isValid
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`)
|
|
16
|
+
|
|
17
|
+
export async function validateUser(context: GetServerSidePropsContext) {
|
|
18
|
+
const validateUserResult = await execute<
|
|
19
|
+
ValidateUserQueryVariables,
|
|
20
|
+
ValidateUserQuery
|
|
21
|
+
>(
|
|
22
|
+
{
|
|
23
|
+
variables: {},
|
|
24
|
+
operation: query,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
headers: { ...context.req.headers },
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
return validateUserResult?.data?.validateUser?.isValid
|
|
32
|
+
}
|
|
File without changes
|
|
File without changes
|