Commit Graph

13 Commits

Author SHA1 Message Date
Jan Jakes
38c6880400 Unify setting no-cache headers, use WP-native nocache_headers() 2024-09-17 17:27:37 +02:00
Jan Jakes
a664186108 Unify setting no-cache headers, use only relevant headers
See also: https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
ee6e22efa3 Regenerate CAPTCHA phrase using a custom request with cachebust to avoid caching
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
758cb09a77 Check for audio file existence before sending headers
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
975f42c56c Remove unnecessary check (it checks for image requirements, not audio)
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
fad5e629af Simplify renderAudio and renderImage
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
71d7f46718 Make captcha session stateless
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
e8cf3d61ef Make captcha phrase stateless
[MAILPOET-6038]
2024-08-05 13:28:52 +02:00
Jan Jakes
10ef9ffce5 Initialize CAPTCHA session and phrase on page load
Previously, a new CAPTCHA phrase was generated when the CAPTCHA image
or audio was requested "again". For that, a counter needed to be stored in the
session, and since image and audio were fetched in parallel, any of them could
initialize the new CAPTCHA phrase. The problem appeared when they both
generated a new phrase at the same time. This resulted in a race condition,
where the image and audio had different CAPTCHA phrases and some users
weren't able to pass the CAPTCHA at all. This was occuring especially in Safari,
(maybe somehow due the type dectection range "preflight" request).

Now, the phrase is initialized on the CAPTCHA page load (and reloaded via AJAX),
so we don't need to store any additional metadata, apart from the phrase itself.

[MAILPOET-6038]x
2024-08-05 13:28:52 +02:00
Rostislav Wolny
39849a61f1 Use default sizes for captcha image in case invalid value is passed
[MAILPOET-6112]
2024-06-24 15:19:43 +02:00
David Remer
3da2144ead Extend audio type by range header
[MAILPOET-5032]
2023-02-08 13:08:09 +01:00
Jan Jakes
926620e8f8 Ignore strict types rule in all existing files that don't have it
[MAILPOET-2688]
2022-11-29 15:04:09 +01:00
David Remer
4832771185 Refactor the captcha system
The current Captcha class has a lot of responsibilities. It renders the captcha
image, can check if a certain captcha type is a Google captcha, if a captcha is
required for a certain email. The SubscriberSubscribeController is not only in
charge of "controlling" the subscription process but also validates, whether a
captcha is correct or not. This architecture made it difficult to extend the
functionality and introduce the audio captcha feature.

Therefore this commit refactors the captcha architecture and tries to seperate
the different concerns into several classes and objects. Validation is now done
by validators.

The CaptchaPhrase now is in charge of keeping the captcha phrase consistent
between the image and the new audio, so that you can renew the captcha and both
captchas are in sync.

[MAILPOET-4514]
2022-11-24 09:20:39 +01:00