diff --git a/PoliteCaptcha/BypassCaptchaGenerator.cs b/PoliteCaptcha/BypassCaptchaGenerator.cs
index f5d04e4..3d8126d 100644
--- a/PoliteCaptcha/BypassCaptchaGenerator.cs
+++ b/PoliteCaptcha/BypassCaptchaGenerator.cs
@@ -4,16 +4,19 @@
namespace PoliteCaptcha
{
+ ///
+ /// A "fake" CAPTCHA generator that effectively bypasses CAPTCHA generation.
+ ///
public class BypassCaptchaGenerator : ICaptchaGenerator
{
///
- /// This is a "fake" CAPTCHA generator that returns nothing, effectively bypassing CAPTCHA generation.
+ /// Generates "fake" CAPTCHA HTML (returns an empty string), effectively bypassing CAPTCHA generation.
///
- /// The view's HTML helper.
+ /// The view's HTML helper.
/// An optional message to display above the CAPTCHA when it is displayed as a fallback.
/// The CAPTCHA's HTML.
public IHtmlString Generate(
- HtmlHelper httpHelper,
+ HtmlHelper htmlHelper,
string fallbackMessage = null)
{
return new MvcHtmlString(string.Empty);
diff --git a/PoliteCaptcha/BypassCaptchaValidator.cs b/PoliteCaptcha/BypassCaptchaValidator.cs
index c2bf100..326bf03 100644
--- a/PoliteCaptcha/BypassCaptchaValidator.cs
+++ b/PoliteCaptcha/BypassCaptchaValidator.cs
@@ -3,10 +3,13 @@
namespace PoliteCaptcha
{
+ ///
+ /// A "fake" CAPTCHA validator that effectively bypasses CAPTCHA validation.
+ ///
public class BypassCaptchaValidator : ICaptchaValidator
{
///
- /// This is a "fake" CAPTCHA validator that always returns true, effectively bypassing CAPTCHA validation.
+ /// "Fakes" CAPTCHA validation (always returns true), effectively bypassing CAPTCHA validation.
///
/// The request's HTTP context.
/// The result of validation; always true.
diff --git a/PoliteCaptcha/Const.cs b/PoliteCaptcha/Const.cs
index 4fce01d..ea4bc7e 100644
--- a/PoliteCaptcha/Const.cs
+++ b/PoliteCaptcha/Const.cs
@@ -2,6 +2,9 @@
namespace PoliteCaptcha
{
+ ///
+ /// The constants used by PoliteCaptcha, all in one convenience place.
+ ///
public static class Const
{
public const string DefaulFallbackMessage = "Your request failed spam prevention. You must complete the CAPTCHA form below to proceed.";
diff --git a/PoliteCaptcha/ICaptchaGenerator.cs b/PoliteCaptcha/ICaptchaGenerator.cs
index 6fda327..a5b988d 100644
--- a/PoliteCaptcha/ICaptchaGenerator.cs
+++ b/PoliteCaptcha/ICaptchaGenerator.cs
@@ -4,10 +4,19 @@
namespace PoliteCaptcha
{
+ ///
+ /// Generates CAPTCHA HTML.
+ ///
public interface ICaptchaGenerator
{
+ ///
+ /// Generates CAPTCHA HTML.
+ ///
+ /// The view's HTML helper.
+ /// An optional message to display above the CAPTCHA when it is displayed as a fallback.
+ /// The CAPTCHA's HTML.
IHtmlString Generate(
- HtmlHelper httpHelper,
+ HtmlHelper htmlHelper,
string fallbackMessage = null);
}
}
diff --git a/PoliteCaptcha/ICaptchaValidator.cs b/PoliteCaptcha/ICaptchaValidator.cs
index 1039c90..556689b 100644
--- a/PoliteCaptcha/ICaptchaValidator.cs
+++ b/PoliteCaptcha/ICaptchaValidator.cs
@@ -3,8 +3,16 @@
namespace PoliteCaptcha
{
+ ///
+ /// Validates a CAPTCHA response.
+ ///
public interface ICaptchaValidator
{
+ ///
+ /// Validates a CAPTCHA response.
+ ///
+ /// The request's HTTP context.
+ /// The result of validation; true or false.
bool Validate(HttpContextBase httpContext);
}
}
\ No newline at end of file
diff --git a/PoliteCaptcha/ReCaptchaGenerator.cs b/PoliteCaptcha/ReCaptchaGenerator.cs
index 232327c..48477bf 100644
--- a/PoliteCaptcha/ReCaptchaGenerator.cs
+++ b/PoliteCaptcha/ReCaptchaGenerator.cs
@@ -8,8 +8,17 @@
namespace PoliteCaptcha
{
+ ///
+ /// A CAPTCHA generator that uses reCAPTCHA; the default CAPTCHA generator used by PoliteCaptcha.
+ ///
public class ReCaptchaGenerator : ICaptchaGenerator
{
+ ///
+ /// Generates CAPTCHA HTML using reCAPTCHA.
+ ///
+ /// The view's HTML helper.
+ /// An optional message to display above the CAPTCHA when it is displayed as a fallback.
+ /// The reCAPTCHA HTML.
public IHtmlString Generate(
HtmlHelper htmlHelper,
string fallbackMessage = null)
diff --git a/PoliteCaptcha/ReCaptchaValidator.cs b/PoliteCaptcha/ReCaptchaValidator.cs
index dffd0a5..021e059 100644
--- a/PoliteCaptcha/ReCaptchaValidator.cs
+++ b/PoliteCaptcha/ReCaptchaValidator.cs
@@ -5,15 +5,26 @@
namespace PoliteCaptcha
{
+ ///
+ /// A CAPTCHA validator that uses reCAPTCHA.
+ ///
public class ReCaptchaValidator : ICaptchaValidator
{
readonly RecaptchaValidator recaptchaValidator;
+ ///
+ /// Creates a new ReCaptchValidator object.
+ ///
public ReCaptchaValidator()
{
recaptchaValidator = new RecaptchaValidator();
}
+ ///
+ /// Validates a CAPTCHA response using reCAPTCHA.
+ ///
+ /// The request's HTTP context.
+ /// The result of validation; true or false.
public bool Validate(HttpContextBase httpContext)
{
if (httpContext == null)
diff --git a/PoliteCaptcha/SpamPreventionHtmlHelpers.cs b/PoliteCaptcha/SpamPreventionHtmlHelpers.cs
index 28a2ab9..ef06199 100644
--- a/PoliteCaptcha/SpamPreventionHtmlHelpers.cs
+++ b/PoliteCaptcha/SpamPreventionHtmlHelpers.cs
@@ -5,8 +5,17 @@
namespace PoliteCaptcha
{
+ ///
+ /// HTML Helpers for PoliteCaptcha' spam prevention.
+ ///
public static class SpamPreventionHtmlHelpers
{
+ ///
+ /// Generates the form fields' HTML for spam prevention. Use inside of an ASP.NET MVC form.
+ ///
+ /// The view's HTML helper.
+ /// An optional message to display above the CAPTCHA when it is displayed as a fallback.
+ /// The spam prevention form fields' HTML
public static IHtmlString SpamPreventionFields(
this HtmlHelper htmlHelper,
string fallbackMessage = null)
@@ -24,6 +33,11 @@ public static class SpamPreventionHtmlHelpers
return htmlHelper.Hidden(Const.NoCaptchaChallengeField, Guid.NewGuid().ToString("N"));
}
+ ///
+ /// Generates the JavaScript required for spam prevention. Requires jQuery.
+ ///
+ /// The view's HTML helper.
+ /// The spam prevention JavaScript.
public static IHtmlString SpamPreventionScript(this HtmlHelper htmlHelper)
{
return new MvcHtmlString(
diff --git a/PoliteCaptcha/ValidateSpamPreventionAttribute.cs b/PoliteCaptcha/ValidateSpamPreventionAttribute.cs
index baa8d6b..22290b5 100644
--- a/PoliteCaptcha/ValidateSpamPreventionAttribute.cs
+++ b/PoliteCaptcha/ValidateSpamPreventionAttribute.cs
@@ -5,9 +5,16 @@
namespace PoliteCaptcha
{
+ ///
+ /// Validates spam prevention; apply to ASP.NET MVC action methods.
+ ///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ValidateSpamPreventionAttribute : FilterAttribute, IAuthorizationFilter
{
+ ///
+ /// Authorizes the current action by validating spam prevention responses.
+ ///
+ /// The filter's authorization context.
public void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext == null)
@@ -31,6 +38,12 @@ public void OnAuthorization(AuthorizationContext filterContext)
captchaValidator);
}
+ ///
+ /// Authorizes spam prevention responses. If validation fails, updates model state accordingly.
+ ///
+ /// The request's HTTP context.
+ /// The request's model state.
+ /// The CAPTCHA validator to use to validate a CAPTCHA response, if present.
public void Authorize(
HttpContextBase httpContext,
ModelStateDictionary modelState,