Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit e03b9f3

Browse files
committed
Fix createEmptyCart request to Spree and add option to disable auto login
1 parent 8c73220 commit e03b9f3

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

framework/spree/.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ NEXT_PUBLIC_SPREE_LINE_ITEM_PLACEHOLDER_IMAGE_URL=/product-img-placeholder.svg
2222
NEXT_PUBLIC_SPREE_IMAGES_OPTION_FILTER=false
2323
NEXT_PUBLIC_SPREE_IMAGES_SIZE=1000x1000
2424
NEXT_PUBLIC_SPREE_IMAGES_QUALITY=100
25+
NEXT_PUBLIC_SPREE_LOGIN_AFTER_SIGNUP=true

framework/spree/auth/use-signup.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import useCustomer from '../customer/use-customer'
1010
import useCart from '../cart/use-cart'
1111
import useWishlist from '../wishlist/use-wishlist'
1212
import login from '../utils/login'
13+
import { requireConfigValue } from '@framework/isomorphic-config'
1314

1415
export default useSignup as UseSignup<typeof handler>
1516

@@ -62,7 +63,9 @@ export const handler: MutationHook<SignupHook> = {
6263
}
6364

6465
// Login immediately after the account is created.
65-
await login(fetch, getTokenParameters, true)
66+
if (requireConfigValue('loginAfterSignup')) {
67+
await login(fetch, getTokenParameters, true)
68+
}
6669

6770
return null
6871
},

framework/spree/isomorphic-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const isomorphicConfig = {
4545
imagesQuality: validateImagesQuality(
4646
process.env.NEXT_PUBLIC_SPREE_IMAGES_QUALITY
4747
),
48+
loginAfterSignup: process.env.NEXT_PUBLIC_SPREE_LOGIN_AFTER_SIGNUP === 'true',
4849
}
4950

5051
export default forceIsomorphicConfigValues(
@@ -68,6 +69,7 @@ export default forceIsomorphicConfigValues(
6869
'imagesOptionFilter',
6970
'imagesSize',
7071
'imagesQuality',
72+
'loginAfterSignup',
7173
]
7274
)
7375

framework/spree/utils/create-empty-cart.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ const createEmptyCart = (
1414
return fetch<GraphQLFetcherResult<IOrder>>({
1515
variables: {
1616
methodPath: 'cart.create',
17-
arguments: [
18-
{
19-
token,
20-
},
21-
],
17+
arguments: [token],
2218
},
2319
})
2420
}

0 commit comments

Comments
 (0)