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
@@ -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>