Protected against bots by Yandex SmartCaptcha. Data processing policy
Captcha
An "I am not a bot" check for a site form. A wrapper: it draws the service's widget above its child and lets the form go only with a token in hand.
Type:
wrapper
Web only:
in the app the element draws its child and
verify
does nothing: an installed app is not an anonymous form.
State @message:"" @proof:""
HttpData url:"https://api.example.com/v1/complaints" method:"POST"
immediate:false watch:false refresh:@send
body:{jsonEncode(mapOf("message", message, "captchaToken", proof))}
Captcha token:@fresh failed:@down verify:@checkHuman
onVerified:(){proof = fresh; send()}
Column
ElevatedButton onPressed:(){checkHuman()}
Text "Send"
Text "Write to us by email." if:$down
Parameters
| Parameter | Type | Description |
|---|---|---|
token
|
output, string | The token for the request. Empty until the check passes, and empty again once it expires |
failed
|
output, bool |
true
when the service is unavailable or not declared in
project.json
|
verify
|
output, function |
The form's button calls it. Starts the check; the request is sent from
onVerified
|
onVerified
|
callback | Runs once there is a token: put it where the request reads it from, and send |
The service and the key are not written in markup — they are declared in `settings.captcha` .
How it works
-
The button calls the check, not the send.
verifystarts the check,onVerifiedfires only with a token. A visible widget the visitor has already ticked sends right away; an unticked one sends as soon as it is ticked. -
The press sends, not the tick.
A token received before the press just lands in
token. -
A token is single-use and short-lived.
The next
verifyafter a send resets the widget by itself and waits for a new token; an expired token becomes empty. - The token is verified by the server the form sends data to, with its own server key. Where to put the token (body, header, field name) is up to the markup, because it is the backend's requirement.
- The widget's look is chosen automatically. Width is at most 400 px, the theme follows the background it stands on: on a dark page the widget is dark. There is nothing to write in markup for this.
Rules
-
MUST
The button and everything that reads the outputs go INSIDE
Captcha: a sibling of the element does not see its outputs, and the button's handler silently does nothing. -
MUST
The request (
HttpData) goes OUTSIDE, above the element: a callback sees what is declared above it. The request body, in turn, does not see the outputs inside, so the token is moved into a page variable (proof = fresh). - MUST The server must verify the token. A token nobody verifies protects against nothing.
-
MUST NOT
The server key is never put in
project.json. -
SHOULD
Show a fallback on
failed: without a token the form never goes out, and a person needs another way to get in touch.
See also
- Session — visitor sign-in; a sign-up form is the first candidate for a captcha
- Script — your own JavaScript on the page
- project.json — declaring the service