Recaptcha for contact and registration page implemented

This commit is contained in:
2022-10-21 14:43:33 -04:00
parent 0160c1d7b5
commit 8fd0796019
10 changed files with 155 additions and 42 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
@using ClientDependency.Core.Mvc
@using hbehr.recaptcha
@using LeafWeb.WebCms.Controllers
@model ContactForm
@{
@@ -7,6 +8,7 @@
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.custom.js", 2);
}
<script type="text/javascript">function submit() { $('form').submit(); }</script>
<div class="container mt-4">
<div class="row justify-content-center">
@@ -18,8 +20,9 @@
@Html.EditorFor(m => m.Name)
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.Message)
<input type="submit" id="submit-form" class="d-none"/>}
<label for="submit-form" class="btn btn-primary pull-right">Send</label>
@ReCaptcha.GetInvisibleCaptcha("submit", "Send")
@* Restyling this button does not appear to allow it to continue operating *@
}
</div>
</div>
</div>
@@ -1,6 +1,7 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using ClientDependency.Core.Mvc
@using Umbraco.Web.Controllers
@using LeafWeb.WebCms.Controllers
@using hbehr.recaptcha
@{
// https://24days.in/umbraco-cms/2015/membership-apis-investigation/
// https://our.umbraco.com/forum/templates-partial-views-and-macros/93133-membership-provider-registration-form
@@ -19,44 +20,45 @@
var user = Membership.GetUser();
}
<script type="text/javascript">function submit() { $('form').submit(); }</script>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-lg-6 card card-body bg-light">
@* ReSharper disable once UnknownCssClass *@
@if (success || (!user?.IsApproved ?? false))
{
<h2 class="text-center"><span class="fa fa-check text-primary"></span> </h2>
<p>Registration succeeded. Please check your email to verify your account.</p>
}
else if (user != null)
{
<p>No need to register - you are already logged with email @user.Email</p>
}
else
{
using (Html.BeginUmbracoForm<UmbRegisterController>(
"HandleRegisterMember",
null,
new {id="register-member"}))
{
@Html.ValidationSummary(false)
@if (success || (!user?.IsApproved ?? false))
{
<h2 class="text-center"><span class="fa fa-check text-primary"></span> </h2>
<p>Registration succeeded. Please check your email (@user.Email) to verify your account.</p>
}
else if (user != null)
{
<p>No need to register - you are already logged in with email @user.Email</p>
}
else
{
using (Html.BeginUmbracoForm<RegisterController>(
"HandleRegisterMember",
null,
new { id = "register-member" }))
{
@Html.ValidationSummary(false)
@Html.EditorFor(m => registerModel.Name, new {labelText = "Name"})
@Html.EditorFor(m => registerModel.Email, new { type = "email", labelText = "Email"})
@Html.EditorFor(m => registerModel.Password, "Password")
<div class="form-group verifyPassword">
@Html.Label("Verify Password")
@Html.Password("VerifyPassword", null, new { @class = "form-control" })
@Html.ValidationMessage("VerifyPassword", "", new { @class = "text-danger" })
</div>
@Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl)
@*@Html.HiddenFor(m => registerModel.UsernameIsEmail)*@
@Html.EditorFor(m => registerModel.Name, new { labelText = "Name" })
@Html.EditorFor(m => registerModel.Email, new { type = "email", labelText = "Email" })
@Html.EditorFor(m => registerModel.Password, "Password")
<div class="form-group verifyPassword">
@Html.Label("Verify Password")
@Html.Password("VerifyPassword", null, new { @class = "form-control" })
@Html.ValidationMessage("VerifyPassword", "", new { @class = "text-danger" })
</div>
@Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl)
@*@Html.HiddenFor(m => registerModel.UsernameIsEmail)*@
<button type="submit" class="btn btn-primary pull-right">Register</button>
}
}
@ReCaptcha.GetInvisibleCaptcha("submit", "Register")
}
}
</div>
</div>
</div>
+1 -1
View File
@@ -7,4 +7,4 @@
</h1>
<p>Permission denied for requested resource. If you believe this to be in error please contact administrator, referencing the following url:</p>
<code>@Html.Raw(Request.Url)</code>
<code>@Html.Raw(Request.UrlReferrer.AbsoluteUri)</code>