[web] add support for regex based allow-list for skipping captcha (#24266)

* [web] double down on validating email addresses

* [web] normalize emails in captcha middleware

* [web] add support for regex based allow-list for skipping captcha

* [web] skip captcha for trusted users on all actions

GitOrigin-RevId: a994ebf6b74e80f462d2dab1fe5113bbffa676a9
This commit is contained in:
Jakob Ackermann
2025-03-24 10:45:53 +00:00
committed by Copybot
parent a7818e9b11
commit e94473a1ce
4 changed files with 33 additions and 6 deletions
@@ -18,6 +18,24 @@ describe('EmailHelper', function () {
expect(parseEmail(address, true)).to.equal(expected)
})
it('should return null for garbage input', function () {
const cases = [
undefined,
null,
'',
42,
['test@example.com'],
{},
{ length: 42 },
{ trim: true, match: true },
{ toString: true },
]
for (const input of cases) {
expect(parseEmail(input)).to.equal(null, input)
expect(parseEmail(input, true)).to.equal(null, input)
}
})
it('should return null for an invalid single email', function () {
const address = 'testexample.com'
expect(parseEmail(address)).to.equal(null)