diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/classes/forms/CaptchaInput.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/classes/forms/CaptchaInput.php')
| -rw-r--r-- | lib/classes/forms/CaptchaInput.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/classes/forms/CaptchaInput.php b/lib/classes/forms/CaptchaInput.php new file mode 100644 index 0000000..6476f87 --- /dev/null +++ b/lib/classes/forms/CaptchaInput.php @@ -0,0 +1,38 @@ +<?php + +namespace Studip\Forms; + +use CaptchaChallenge; +use URLHelper; + +/** + * The Text class represents a part of a form that displays a captcha. + */ +final class CaptchaInput extends Input +{ + public function hasValidation(): bool + { + return true; + } + + public function getValidationCallback(): callable + { + return fn($value) => \CaptchaChallenge::validatePayload($value); + } + + public function render(): string + { + return sprintf( + '<captcha-input challenge-url="%s" v-model="%s" auto="onload"></captcha-input>', + URLHelper::getLink('dispatch.php/captcha/challenge', [], true), + htmlReady($this->name) + ); + } + + public function renderWithCondition(): string + { + return $this->render(); + } + + +} |
