Skip to content

Commit 43c267f

Browse files
committed
Updating the documentations of the tag helper classes.
1 parent d5fef5d commit 43c267f

File tree

4 files changed

+155
-7
lines changed

4 files changed

+155
-7
lines changed

docs/Griesoft.AspNetCore.ReCaptcha.xml

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ReCaptcha/TagHelpers/RecaptchaInvisibleTagHelper.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
1111
{
1212
/// <summary>
13-
/// Add a invisible reCAPTCHA div element to your page. Or add a 're-invisible' attribute to a button element to bind the invisible captcha to a button.
13+
/// Add a invisible reCAPTCHA div element to your page. You may also use it by adding a 're-invisible' attribute to a button
14+
/// element which will automatically bind the challenge to it.
1415
/// </summary>
1516
/// <remarks>
1617
/// The <see cref="FormId"/> is required. With the exception that you set a <see cref="Callback"/> instead.
@@ -22,6 +23,17 @@ namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
2223
/// If the tag is not inside the form that is going to be submitted, you should use a custom callback function. The default callback function
2324
/// does not add the reCAPTCHA token to the form, which will result in response verification failure.
2425
/// </remarks>
26+
/// <example>
27+
/// The simplest use of the tag would be:
28+
/// <code>
29+
/// <button re-invisible formid="myForm">Submit</button>
30+
/// </code>
31+
///
32+
/// Which will translate into the following HTML:
33+
/// <code>
34+
/// <button class="g-recaptcha" data-sitekey="your_site_key" data-callback="submitmyForm" data-badge="bottomleft">Submit</button>
35+
/// </code>
36+
/// </example>
2537
[HtmlTargetElement("recaptcha-invisible", Attributes = "callback", TagStructure = TagStructure.WithoutEndTag)]
2638
[HtmlTargetElement("recaptcha-invisible", Attributes = "formid", TagStructure = TagStructure.WithoutEndTag)]
2739
[HtmlTargetElement("button", Attributes = "re-invisible,callback")]
@@ -66,12 +78,13 @@ public RecaptchaInvisibleTagHelper(IOptionsMonitor<RecaptchaSettings> settings,
6678

6779
/// <summary>
6880
/// The id of the form that will be submitted after a successful reCAPTCHA challenge.
69-
/// This does only apply when not specifying a custom <see cref="Callback"/>.
7081
/// </summary>
82+
/// <remarks>This does only apply when not specifying a <see cref="Callback"/>.</remarks>
7183
public string? FormId { get; set; }
7284

7385
/// <summary>
74-
/// Set the name of your callback function, executed when the user submits a successful response. The "g-recaptcha-response" token is passed to your callback.
86+
/// Set the name of your callback function, which is called when the reCAPTCHA challenge was successful.
87+
/// A "g-recaptcha-response" token is added to your callback function parameters for server-side verification.
7588
/// </summary>
7689
public string Callback { get; set; } = string.Empty;
7790

src/ReCaptcha/TagHelpers/RecaptchaScriptTagHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
99
{
1010
/// <summary>
11-
/// Adds a script tag, which will load the required reCAPTCHA JavaScript API. Can be added
12-
/// anywhere on your HTML page, but if you use a onload callback function you must place this
13-
/// after that callback to avoid race conditions.
11+
/// Adds a script tag, which will load the required reCAPTCHA API.
1412
/// </summary>
13+
/// <remarks>
14+
/// In case that you use an onload callback function you must place this tag after the callback script, to avoid race conditions.
15+
/// </remarks>
1516
[HtmlTargetElement("recaptcha-script", TagStructure = TagStructure.WithoutEndTag)]
1617
public class RecaptchaScriptTagHelper : TagHelper
1718
{

src/ReCaptcha/TagHelpers/RecaptchaTagHelper.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,24 @@
88
namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
99
{
1010
/// <summary>
11-
/// A tag helper which adds a Google reCAPTCHA div element to your page.
11+
/// A tag helper which adds a Google reCAPTCHA check box to your page.
1212
/// </summary>
13+
/// <remarks>
14+
/// If the reCAPTCHA element is outside of the form, the response token is not included in your form which will result in response verification failure.
15+
/// This can be prevented by either placing the reCAPTCHA inside your form or by using a callback function which will add the token to your form after the
16+
/// challenge was successfully completed.
17+
/// </remarks>
18+
/// <example>
19+
/// The simplest use of the tag would be:
20+
/// <code>
21+
/// <recaptcha />
22+
/// </code>
23+
///
24+
/// Which will translate into the following HTML:
25+
/// <code>
26+
/// <div class="g-recaptcha" data-sitekey="your_site_key" data-size="normal" data-theme="light"></div>
27+
/// </code>
28+
/// </example>
1329
public class RecaptchaTagHelper : TagHelper
1430
{
1531
private readonly RecaptchaSettings _settings;

0 commit comments

Comments
 (0)