Added recaptcha to the signup page in hopes of keeping more spammers out

This commit is contained in:
Sebastiaan Janssen
2014-07-20 12:23:10 +02:00
parent 5674a92e21
commit 1e190ac9c7
11 changed files with 103 additions and 11 deletions
+1
View File
@@ -42,3 +42,4 @@ build/*.nupkg
/packages/*
!packages/repositories.config
OurUmbraco.Site/App_Data/YouTrack/all.json
OurUmbraco.Site/App_Data/communityblogs.xml
+3 -1
View File
@@ -381,7 +381,9 @@
<Content Include="config\uPowers.config" />
<Content Include="config\UrlRewriting.config" />
<Content Include="config\uVersion.backup.config" />
<Content Include="config\uVersion.config" />
<Content Include="config\uVersion.config">
<SubType>Designer</SubType>
</Content>
<Content Include="config\xsltExtensions.config" />
<Content Include="css\forum\pagedown.css" />
<Content Include="css\img\select2-spinner.gif" />
@@ -1,5 +1,5 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Signup.ascx.cs" Inherits="our.usercontrols.Signup" %>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<asp:panel ID="MemberExists" Visible="False" runat="server">
<p>There is already an account with this e-mail address! You can <a href="/member/login">login</a> or <a href="/member/forgot-password">reset your password</a>.</p>
@@ -10,7 +10,7 @@
<fieldset>
<legend>Basic Information</legend>
<p>
We just need the most basic information from you.
We just need the most basic information from you....
</p>
<p>
<asp:label ID="Label1" AssociatedControlID="tb_name" CssClass="inputLabel" runat="server">Name</asp:label>
@@ -33,6 +33,7 @@
<asp:TextBox ID="tb_bio" runat="server" TextMode="MultiLine" CssClass="title noHtml"/>
</p>
</fieldset>
<fieldset>
@@ -90,7 +91,14 @@
<br />
</fieldset>
<fieldset>
<legend>Are you human?</legend>
<p>
<asp:Label runat="server" ID="lbl_recaptcha" AssociatedControlID="recaptcha">Please complete the following captcha</asp:Label>
<recaptcha:RecaptchaControl ID="recaptcha" runat="server" Theme="clean" PublicKey="6LeHJfcSAAAAADyRdX4f_z79H7iH3rjggZcXFWio" />
<asp:Label runat="server" CssClass="error" ID="err_recaptcha" Visible="False">Please type the text as it appears in the image(s) above.</asp:Label>
</p>
</fieldset>
<div class="buttons">
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+16 -1
View File
@@ -22,6 +22,8 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -70,6 +72,9 @@
<Reference Include="Microsoft.ApplicationBlocks.Data">
<HintPath>..\dependencies\4.9.1\Microsoft.ApplicationBlocks.Data.dll</HintPath>
</Reference>
<Reference Include="Recaptcha">
<HintPath>..\packages\recaptcha.1.0.5.0\lib\.NetFramework 4.0\Recaptcha.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -326,7 +331,10 @@
</Content>
<Content Include="usercontrols\ProjectContributors.ascx" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@@ -345,4 +353,11 @@
<PropertyGroup>
<PostBuildEvent>XCOPY "$(ProjectDir)usercontrols\*.ascx" "$(ProjectDir)..\OurUmbraco.Site\usercontrols\our.umbraco.org" /y</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="recaptcha" version="1.0.5.0" targetFramework="net40" />
</packages>
+11 -3
View File
@@ -1,5 +1,5 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Signup.ascx.cs" Inherits="our.usercontrols.Signup" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Signup.ascx.cs" Inherits="our.usercontrols.Signup" %>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<asp:panel ID="MemberExists" Visible="False" runat="server">
<p>There is already an account with this e-mail address! You can <a href="/member/login">login</a> or <a href="/member/forgot-password">reset your password</a>.</p>
@@ -33,6 +33,7 @@
<asp:TextBox ID="tb_bio" runat="server" TextMode="MultiLine" CssClass="title noHtml"/>
</p>
</fieldset>
<fieldset>
@@ -90,7 +91,14 @@
<br />
</fieldset>
<fieldset>
<legend>Are you human?</legend>
<p>
<asp:Label runat="server" ID="lbl_recaptcha" AssociatedControlID="recaptcha">Please complete the following captcha</asp:Label>
<recaptcha:RecaptchaControl ID="recaptcha" runat="server" Theme="clean" PublicKey="6LeHJfcSAAAAADyRdX4f_z79H7iH3rjggZcXFWio" />
<asp:Label runat="server" CssClass="error" ID="err_recaptcha" Visible="False">Please type the text as it appears in the image(s) above.</asp:Label>
</p>
</fieldset>
<div class="buttons">
+16 -2
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
@@ -25,6 +27,8 @@ namespace our.usercontrols
//lazyloading the needed javascript for validation. (addded it to the master template as our ahah forms need it aswel)
//umbraco.library.RegisterJavaScriptFile("jquery.validation", "/scripts/jquery.validation.js");
recaptcha.PrivateKey = ConfigurationManager.AppSettings["RecaptchaPrivateKey"];
MemberExists.Visible = false;
if (!Page.IsPostBack && m != null)
@@ -62,7 +66,17 @@ namespace our.usercontrols
tb_location.Text = m.getProperty("location").Value.ToString();
}
// ReCaptcha is wrong when Page.IsValid is false
Page.Validate();
if (Page.IsPostBack && Page.IsValid == false)
{
tb_password.Attributes["value"] = tb_password.Text;
err_recaptcha.Visible = true;
}
else
{
err_recaptcha.Visible = false;
}
}
protected void createMember(object sender, EventArgs e)
@@ -109,7 +123,7 @@ namespace our.usercontrols
}
else
{
if (tb_email.Text != "")
if (tb_email.Text != "" && Page.IsValid)
{
m = Member.GetMemberFromLoginName(tb_email.Text);
if (m == null)
+27
View File
@@ -237,6 +237,33 @@ namespace our.usercontrols {
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField tb_lng;
/// <summary>
/// lbl_recaptcha control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lbl_recaptcha;
/// <summary>
/// recaptcha control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::Recaptcha.RecaptchaControl recaptcha;
/// <summary>
/// err_recaptcha control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label err_recaptcha;
/// <summary>
/// bt_submit control.
/// </summary>
+1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\our.umbraco.org\packages.config" />
<repository path="..\OurUmbraco.Site\packages.config" />
<repository path="..\uDocumentation\packages.config" />
<repository path="..\uForum\packages.config" />
+2 -1
View File
@@ -90,7 +90,8 @@ namespace uWiki.Businesslogic
if (Directory.Exists(HttpContext.Current.Server.MapPath(path)) == false)
Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path));
path = string.Format("{0}/{1}_{2}.{3}", path, DateTime.Now.Ticks, umbraco.cms.helpers.url.FormatUrl(filename), extension);
file.SaveAs(HttpContext.Current.Server.MapPath(path));