@@ -1,6 +1,6 @@
{
"name": "auth0-lock",
"version": "11.20.1",
"version": "11.20.2",
"description": "Auth0 Lock",
"author": "Auth0 <support@auth0.com> (http://auth0.com)",
"license": "MIT",
@@ -28,8 +28,9 @@ export function logIn(id, needsMFA = false) {

const fields = [usernameField, 'password'];

const captcha = c.getFieldValue(m, 'captcha');
if (captcha) {
const isCaptchaRequired = l.captcha(m) && l.captcha(m).get('required');
if (isCaptchaRequired) {
const captcha = c.getFieldValue(m, 'captcha');
params['captcha'] = captcha;
fields.push('captcha');
}
@@ -34,6 +34,7 @@ const Captcha = ({ lock, i18n, onReload }) => {
onChange={handleChange}
onReload={onReload}
value={value}
invalidHint={i18n.str('blankErrorHint')}
/>
);
};
@@ -39,8 +39,9 @@ describe('captcha', function() {
it('should require another challenge when clicking the refresh button', function(done) {
h.clickRefreshCaptchaButton(this.lock);
setTimeout(() => {
expect(h.q(this.lock, '.auth0-lock-captcha-image').style.backgroundImage)
.to.equal(`url("${requiredResponse2.image}")`);
expect(h.q(this.lock, '.auth0-lock-captcha-image').style.backgroundImage).to.equal(
`url("${requiredResponse2.image}")`
);
done();
}, 200);
});
@@ -49,6 +50,11 @@ describe('captcha', function() {
h.logInWithEmailPasswordAndCaptcha(this.lock);
expect(h.wasLoginAttemptedWith({ captcha: 'captchaValue' })).to.be.ok();
});

it('should not submit the form if the captcha is not provided', function() {
h.logInWithEmailAndPassword(this.lock);
expect(h.wasLoginAttemptedWith({})).to.not.be.ok();
});
});

describe('when the challenge api returns required: false', function() {