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

[SD-172] Added support for CAPTCHAs in webforms #1320

Open
wants to merge 16 commits into
base: release/2.17.0
Choose a base branch
from

Conversation

jeffdowdle
Copy link
Contributor

@jeffdowdle jeffdowdle commented Sep 10, 2024

Issue: https://digital-vic.atlassian.net/browse/SD-172

Screenshot 2024-09-16 at 2 44 06 PM

What I did

How to test

Checklist

For all PR's

  • I've added relevant changes to the project Readme if needed.
  • I've updated the documentation site as needed.
  • I have added unit tests to cover my changes (if not applicable, please state why in a comment)

For new components only

  • I have added a story covering all variants
  • I have checked a11y tab in storybook passes
  • Any events are emitted on the event bus

</script>
<template>
<div v-if="captchaElementId" :id="captchaElementId"></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If applicable, the captcha checkbox/badge will be rendered here

}
}

export const getCaptchaResponse = async (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is called on submit of the form to get the captcha token

@@ -29,7 +37,8 @@ export function useWebformSubmit(formId: string) {
site: config.tide.site
},
headers: {
'Content-Type': 'application/vnd.api+json;charset=UTF-8'
'Content-Type': 'application/vnd.api+json;charset=UTF-8',
'x-captcha-response': maybeCaptchaResponse || undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The captcha token is sent via a header to the nuxt server endpoint

}
}

const verifyCaptcha = async (event: H3Event) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where we take the token generated in the browser and validate it which the CAPTCHA provider, this needs to happen server side.

We have to get the webform from drupal here to check if the captcha is enabled or not.

Copy link

cypress bot commented Sep 10, 2024

ripple-framework    Run #2236

Run Properties:  status check passed Passed #2236  •  git commit a66b177104: feat(@dpc-sdp/ripple-tide-webform): only load captcha scripts when captcha eleme...
Project ripple-framework
Branch Review feature/SD-172-captcha-support
Run status status check passed Passed #2236
Run duration 08m 37s
Commit git commit a66b177104: feat(@dpc-sdp/ripple-tide-webform): only load captcha scripts when captcha eleme...
Committer Jeffrey Dowdle
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 196
View all changes introduced in this branch ↗︎

@dylankelly dylankelly added this to the 2.17.0 milestone Sep 15, 2024
@jeffdowdle jeffdowdle changed the base branch from release/2.16.0 to release/2.17.0 September 16, 2024 00:19
@jeffdowdle jeffdowdle marked this pull request as ready for review September 16, 2024 00:20
@jeffdowdle jeffdowdle marked this pull request as draft September 17, 2024 00:42
@jeffdowdle jeffdowdle marked this pull request as ready for review September 18, 2024 22:44
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.

3 participants