Recaptcha for contact and registration page implemented
This commit is contained in:
@@ -11,21 +11,30 @@ namespace LeafWeb.WebCms.Controllers
|
||||
public ActionResult Index()
|
||||
{
|
||||
var viewModel = new ContactForm();
|
||||
return PartialView(viewModel);
|
||||
// if user is logged in, pre fill the name and email
|
||||
var member = Members.GetCurrentMember();
|
||||
if (member != null)
|
||||
{
|
||||
viewModel.Name = member.Name;
|
||||
viewModel.Email= (string)member.GetProperty("Email").Value;
|
||||
|
||||
}
|
||||
return PartialView(viewModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateRecaptcha]
|
||||
public ActionResult Submit(ContactForm viewModel)
|
||||
{
|
||||
if (ModelState.IsValid) // HttpParamMatch indicates it's backing out from Confirm
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
BackgroundJob.Enqueue<EmailNotificationService>(
|
||||
BackgroundJob.Enqueue<EmailNotificationService>(
|
||||
e => e.SendContactEmail(viewModel));
|
||||
|
||||
var logger = LogManager.GetLogger(GetType());
|
||||
logger.Info($"Contact: Name:{viewModel.Name} Added, Email:{viewModel.Email}, Message:{viewModel.Message}");
|
||||
|
||||
SetStatusMessage("Your message has been sent!", StatusType.Success);
|
||||
SetStatusMessage($"Thank you, {viewModel.Name}. Your message has been sent" , StatusType.Success);
|
||||
return RedirectToCurrentUmbracoPage();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user