-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ReCaptcha now using the
recaptchaV3Config
query and add a fallback …
…for Magento 2.4.6 and earlier to still use the configuration. Magento 2.4.7 doesn't need that configuration anymore.
- Loading branch information
Showing
13 changed files
with
104 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@graphcommerce/googlerecaptcha': patch | ||
'@graphcommerce/graphql': patch | ||
--- | ||
|
||
ReCaptcha now using the `recaptchaV3Config` query and add a fallback for Magento 2.4.6 and earlier to still use the configuration. Magento 2.4.7 doesn't need that configuration anymore. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query RecaptchaV3Config { | ||
recaptchaV3Config { | ||
website_key | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { storefrontFromContext, type Resolvers } from '@graphcommerce/graphql-mesh' | ||
|
||
export const resolvers: Resolvers = { | ||
Query: { | ||
recaptchaV3Config: (root, args, context, info) => { | ||
const config = storefrontFromContext(context) | ||
const key = config?.googleRecaptchaKey ?? import.meta.graphCommerce.googleRecaptchaKey | ||
|
||
if (!key) return null | ||
return { | ||
website_key: key, | ||
minimum_score: 0, | ||
badge_position: '', | ||
failure_message: '', | ||
is_enabled: !!key, | ||
forms: [ | ||
'PLACE_ORDER', | ||
'CONTACT', | ||
'CUSTOMER_LOGIN', | ||
'CUSTOMER_FORGOT_PASSWORD', | ||
'CUSTOMER_CREATE', | ||
'CUSTOMER_EDIT', | ||
'NEWSLETTER', | ||
'PRODUCT_REVIEW', | ||
'SENDFRIEND', | ||
'BRAINTREE', | ||
], | ||
} | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { meshConfig as meshConfigBase } from '@graphcommerce/graphql-mesh/meshConfig' | ||
import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config' | ||
|
||
export const config: PluginConfig = { | ||
module: '@graphcommerce/graphql-mesh/meshConfig', | ||
type: 'function', | ||
} | ||
|
||
export const meshConfig: FunctionPlugin<typeof meshConfigBase> = ( | ||
prev, | ||
baseConfig, | ||
graphCommerceConfig, | ||
) => { | ||
if (graphCommerceConfig.magentoVersion <= 247 || !graphCommerceConfig.googleRecaptchaKey) | ||
return prev(baseConfig, graphCommerceConfig) | ||
return prev( | ||
{ | ||
...baseConfig, | ||
additionalResolvers: [ | ||
...(baseConfig.additionalResolvers ?? []), | ||
'@graphcommerce/googlerecaptcha/mesh/resolvers.ts', | ||
], | ||
}, | ||
graphCommerceConfig, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters