Permalink
Browse files

added XML doc in preparation for generating a NuGet package

  • Loading branch information...
1 parent ef2e523 commit e2f02a85adb1337d9099a98a0b7bbc2319de70bc @half-ogre half-ogre committed Feb 7, 2012
@@ -4,16 +4,19 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// A "fake" CAPTCHA generator that effectively bypasses CAPTCHA generation.
+ /// </summary>
public class BypassCaptchaGenerator : ICaptchaGenerator
{
/// <summary>
- /// 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.
/// </summary>
- /// <param name="httpHelper">The view's HTML helper.</param>
+ /// <param name="htmlHelper">The view's HTML helper.</param>
/// <param name="fallbackMessage">An optional message to display above the CAPTCHA when it is displayed as a fallback.</param>
/// <returns>The CAPTCHA's HTML.</returns>
public IHtmlString Generate(
- HtmlHelper httpHelper,
+ HtmlHelper htmlHelper,
string fallbackMessage = null)
{
return new MvcHtmlString(string.Empty);
@@ -3,10 +3,13 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// A "fake" CAPTCHA validator that effectively bypasses CAPTCHA validation.
+ /// </summary>
public class BypassCaptchaValidator : ICaptchaValidator
{
/// <summary>
- /// This is a "fake" CAPTCHA validator that always returns true, effectively bypassing CAPTCHA validation.
+ /// "Fakes" CAPTCHA validation (always returns true), effectively bypassing CAPTCHA validation.
/// </summary>
/// <param name="httpContext">The request's HTTP context.</param>
/// <returns>The result of validation; always true.</returns>
View
@@ -2,6 +2,9 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// The constants used by PoliteCaptcha, all in one convenience place.
+ /// </summary>
public static class Const
{
public const string DefaulFallbackMessage = "Your request failed spam prevention. You must complete the CAPTCHA form below to proceed.";
@@ -4,10 +4,19 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// Generates CAPTCHA HTML.
+ /// </summary>
public interface ICaptchaGenerator
{
+ /// <summary>
+ /// Generates CAPTCHA HTML.
+ /// </summary>
+ /// <param name="htmlHelper">The view's HTML helper.</param>
+ /// <param name="fallbackMessage">An optional message to display above the CAPTCHA when it is displayed as a fallback.</param>
+ /// <returns>The CAPTCHA's HTML.</returns>
IHtmlString Generate(
- HtmlHelper httpHelper,
+ HtmlHelper htmlHelper,
string fallbackMessage = null);
}
}
@@ -3,8 +3,16 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// Validates a CAPTCHA response.
+ /// </summary>
public interface ICaptchaValidator
{
+ /// <summary>
+ /// Validates a CAPTCHA response.
+ /// </summary>
+ /// <param name="httpContext">The request's HTTP context.</param>
+ /// <returns>The result of validation; true or false.</returns>
bool Validate(HttpContextBase httpContext);
}
}
@@ -8,8 +8,17 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// A CAPTCHA generator that uses reCAPTCHA; the default CAPTCHA generator used by PoliteCaptcha.
+ /// </summary>
public class ReCaptchaGenerator : ICaptchaGenerator
{
+ /// <summary>
+ /// Generates CAPTCHA HTML using reCAPTCHA.
+ /// </summary>
+ /// <param name="htmlHelper">The view's HTML helper.</param>
+ /// <param name="fallbackMessage">An optional message to display above the CAPTCHA when it is displayed as a fallback.</param>
+ /// <returns>The reCAPTCHA HTML.</returns>
public IHtmlString Generate(
HtmlHelper htmlHelper,
string fallbackMessage = null)
@@ -5,15 +5,26 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// A CAPTCHA validator that uses reCAPTCHA.
+ /// </summary>
public class ReCaptchaValidator : ICaptchaValidator
{
readonly RecaptchaValidator recaptchaValidator;
+ /// <summary>
+ /// Creates a new ReCaptchValidator object.
+ /// </summary>
public ReCaptchaValidator()
{
recaptchaValidator = new RecaptchaValidator();
}
+ /// <summary>
+ /// Validates a CAPTCHA response using reCAPTCHA.
+ /// </summary>
+ /// <param name="httpContext">The request's HTTP context.</param>
+ /// <returns>The result of validation; true or false.</returns>
public bool Validate(HttpContextBase httpContext)
{
if (httpContext == null)
@@ -5,8 +5,17 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// HTML Helpers for PoliteCaptcha' spam prevention.
+ /// </summary>
public static class SpamPreventionHtmlHelpers
{
+ /// <summary>
+ /// Generates the form fields' HTML for spam prevention. Use inside of an ASP.NET MVC form.
+ /// </summary>
+ /// <param name="htmlHelper">The view's HTML helper.</param>
+ /// <param name="fallbackMessage">An optional message to display above the CAPTCHA when it is displayed as a fallback.</param>
+ /// <returns>The spam prevention form fields' HTML</returns>
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"));
}
+ /// <summary>
+ /// Generates the JavaScript required for spam prevention. Requires jQuery.
+ /// </summary>
+ /// <param name="htmlHelper">The view's HTML helper.</param>
+ /// <returns>The spam prevention JavaScript.</returns>
public static IHtmlString SpamPreventionScript(this HtmlHelper htmlHelper)
{
return new MvcHtmlString(
@@ -5,9 +5,16 @@
namespace PoliteCaptcha
{
+ /// <summary>
+ /// Validates spam prevention; apply to ASP.NET MVC action methods.
+ /// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ValidateSpamPreventionAttribute : FilterAttribute, IAuthorizationFilter
{
+ /// <summary>
+ /// Authorizes the current action by validating spam prevention responses.
+ /// </summary>
+ /// <param name="filterContext">The filter's authorization context.</param>
public void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext == null)
@@ -31,6 +38,12 @@ public void OnAuthorization(AuthorizationContext filterContext)
captchaValidator);
}
+ /// <summary>
+ /// Authorizes spam prevention responses. If validation fails, updates model state accordingly.
+ /// </summary>
+ /// <param name="httpContext">The request's HTTP context.</param>
+ /// <param name="modelState">The request's model state.</param>
+ /// <param name="captchaValidator">The CAPTCHA validator to use to validate a CAPTCHA response, if present.</param>
public void Authorize(
HttpContextBase httpContext,
ModelStateDictionary modelState,

0 comments on commit e2f02a8

Please sign in to comment.