Skip to content

Commit

Permalink
Fix race condition bug with Simple Captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
TSLarson committed Oct 7, 2024
1 parent 9198b14 commit 480f75d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
10 changes: 10 additions & 0 deletions src/connection/passwordless/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export function initPasswordless(m, opts) {
const showTerms = opts.showTerms === undefined ? true : !!opts.showTerms;

m = initNS(m, Map({ send, mustAcceptTerms, showTerms }));

m = sync(m, 'passwordlessCaptcha', {
syncFn: (m, cb) => {
webAPI.getPasswordlessChallenge(m.get('id'), (err, r) => {
cb(null, r);
});
},
successFn: l.setPasswordlessCaptcha
});

if (opts.defaultLocation && typeof opts.defaultLocation === 'string') {
m = initLocation(m, opts.defaultLocation.toUpperCase());
} else {
Expand Down
31 changes: 1 addition & 30 deletions src/core/remote_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import * as l from './index';
import { isADEnabled } from '../connection/enterprise'; // shouldn't depend on this
import sync, { isSuccess } from '../sync';
import webApi from './web_api';
import { setCaptcha, setPasswordlessCaptcha, setPasswordResetCaptcha } from '../core/index';
import { setSignupChallenge } from './index';
import { setCaptcha } from '../core/index';

export function syncRemoteData(m) {
if (l.useTenantInfo(m)) {
Expand Down Expand Up @@ -61,33 +60,5 @@ export function syncRemoteData(m) {
successFn: setCaptcha
});

m = sync(m, 'signupCaptcha', {
syncFn: (m, cb) => {
webApi.getSignupChallenge(m.get('id'), (err, r) => {
cb(null, r);
});
},
successFn: setSignupChallenge
});

m = sync(m, 'passwordlessCaptcha', {
syncFn: (m, cb) => {
webApi.getPasswordlessChallenge(m.get('id'), (err, r) => {
cb(null, r);
});
},
successFn: setPasswordlessCaptcha
});

m = sync(m, 'passwordResetCaptcha', {
syncFn: (m, cb) => {
webApi.getPasswordResetChallenge(m.get('id'), (err, r) => {
cb(null, r);
});
},
successFn: setPasswordResetCaptcha
});


return m;
}

0 comments on commit 480f75d

Please sign in to comment.