-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adding recaptcha_v3 #2031
Adding recaptcha_v3 #2031
Conversation
const { Identity, isInitialized } = useIdentity(); | ||
const [captchaToken, setCaptchaToken] = useState(); | ||
const [resetRecaptcha, setResetRecaptcha] = useState(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of this variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @edwardcho1231 similar to reCaptchav2, reCaptchav3 also expires, but in order to grab a new token we need to call executeRecaptcha(). Thus, resetRecaptcha is changing from true to false and viceversa everytime the reCaptcha3 is expired, thus the useEffect() detects this change and we need to grab a new one.
|
||
const checkCaptcha = async () => { | ||
const identityConfig = await Identity.getConfig(); | ||
console.log(identityConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
data-testid="bot-challege-protection-container" | ||
> | ||
<ReCAPTCHA sitekey={siteKey} onChange={onChange} onExpired={() => {}}/> | ||
{captchaError && <Paragraph>{phrases.t("identity-block.bot-protection-error")}</Paragraph>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting an error when trying to log-in with recaptcha v2 without clicking reCaptcha box. Error says that Paragraph is not defined. I think we need import statement for Paragraph
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few issues I see, should be quick fixes. One other thing to note, the root package-lock.json
has a lot of changes, please make sure this branch is up to date and you're using Node 18 when running npm i
.
"react-google-recaptcha": "^3.1.0", | ||
"react-google-recaptcha-v3": "^1.10.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure these are included as devDependencies in the root package.json, otherwise unit tests will fail (and they are in the test and lint action).
"width": "100%", | ||
"margin": 0, | ||
"line-height": "150%", | ||
"font-size": "1rem", | ||
"margin-bottom": "var(--global-spacing-5)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width, margin, and margin-bottom need to be converted to logical properties.
"margin-bottom": "var(--global-spacing-5)", | ||
"components": { | ||
"paragraph": { | ||
"font-family": "Inter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this font-family is hard coded to Inter and not using "var(--font-family-primary)"
(which defaults to Inter out of the box)? I'm seeing this in a few other places too.
"default": { | ||
"font-family": "inter", | ||
"text-align": "center", | ||
"margin-bottom": "var(--global-spacing-4)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be margin-block-end
.
"font-family": "var(--font-family-primary)", | ||
"font-family": "Inter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LauraPinilla , looks like this got flipped. Can it use the var
like news.json
does?
There are two failing tests, and some linting errors. Run |
@LauraPinilla , it looks like the last tests you added have a couple of small linting errors. Could you fix those? Thanks. We just re-enabled our pre-commit and pre-push hooks so you should see any linting errors before hand if you pull the latest from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good now, approving!
20be316
into
arc-themes-release-version-2.3.0
If you have not filled out the checklist below, the pr is not ready for review.
Description
Render reCaptcha v3 in case the tenant has this config.
We are passing a parameter
reCaptcha V3 is the invisible reCaptcha provided by google. Once it's included on the page should look like the image below.
By default, google includes this in the bottom right corner.
reCaptcha v3 does not require action by the user, the recaptcha is returned automatically.
BotChallengeProtection component will accept a challengeIn attribute. This attribute could be one of:
'signup' || ‘signin’ || ‘magiclink’ || ‘checkout’
IF !!`${challengeIn}Recaptcha && (0 <=recaptchaScore && recaptchaScore <= 1) && !!recaptchaSiteKey
THEN render reCaptchaV3. reCaptchaV3 should be initialized by passing the recaptchaSiteKey
Currently, we have this enabled for org:subssinglesite site:the-daily-intelligencer env: sandbox admin.
findeIn case you need this setting for any tenant, please let us know.
Jira Ticket
ASUB-8193
Acceptance Criteria
Update BotChallengeProtection component in identity-block
BotChallengeProtection will accept a challengeIn attribute. This attribute could be one of:
'signup' || ‘signin’ || ‘magiclink’ || ‘checkout’
IF !!`${challengeIn}Recaptcha && recaptchaScore between 0 - 1 &&!!recaptchaSiteKey
THEN render reCaptchaV3. reCaptchaV3 should be initialized by passing the recaptchaSiteKey
Every time you grab a response token from reCAPTCHA component, store the response in localStorage.
The BotChallengeProtection should be part of the Login block, and the reCaptcha token should be sent during the call to Identity.login();
User should be successfully Logged In when reCaptcha v3 is enabled for signin.
Test Steps
Figma file
Checkout this branch
git checkout ASUB-8193_ReCaptcha_V3
npx fusion start -l @wpmedia/identity-block
point the site configs on
blocks.json
tohttps://subssinglesite-the-daily-intelligencer-sandbox.api.cdn.arcpublishing.com/
(It has recaptchav3 enabled for signin), or enable the config for the tenant you are using.Create a page and includeIdentity Log In - Arc Block component. Check the component BotChallengeProtection is being rendered (reCaptcha v2 or reCaptchaV3, depending on the configs), and after ask for login the user should be logged In successfully.
Effect Of Changes
Before
Example: When I clicked the search button, the button turned red.
[include screenshot or gif or link to video, storybook would be awesome]
After
Example: When I clicked the search button, the button turned green.
[include screenshot or gif or link to video, storybook would be awesome]
Dependencies or Side Effects
Examples of dependencies or side effects are:
Author Checklist
The author of the PR should fill out the following sections to ensure this PR is ready for review.
npm run lint
to check for errors. Often,npm run lint:fix
will fix those errors and warnings.npm run test:coverage
to see your progress.npm run test
, made sure all tests are passingplease explain why (so that we can fix it whenever it gets refactored).
Reviewer Checklist
The reviewer of the PR should copy-paste this template into the review comments on review.