Add registration page

This commit is contained in:
2019-12-15 21:18:51 -05:00
parent 16c4fe8999
commit 7a4946f4f4
13 changed files with 298 additions and 81 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Web.Mvc;
namespace LeafWeb.WebCms.Controllers
{
// http://stackoverflow.com/a/9036075/99492
// TODO http://stackoverflow.com/a/9036075/99492
public class EnforceTrueAttribute : ValidationAttribute, IClientValidatable
{
public override bool IsValid(object value)
@@ -0,0 +1,29 @@
using Hangfire;
using LeafWeb.WebCms.Services;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace LeafWeb.WebCms.EventHandlers
{
// https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/64185-Assign-new-members-to-member-group-upon-registration#comment-254768
public class MemberRegistrationEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
MemberService.Created += MemberService_Created;
}
private void MemberService_Created(IMemberService sender, NewEventArgs<IMember> e)
{
sender.AssignRole(e.Entity.Username, "Unverified");
sender.Save(e.Entity);
// Send Email
BackgroundJob.Enqueue<EmailNotificationService>(
email => email.SendVerifyMemberEmail(e.Entity));
}
}
}
+6 -2
View File
@@ -1,7 +1,5 @@
using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using log4net;
@@ -9,6 +7,7 @@ using LeafWeb.Core.DAL;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
using LeafWeb.WebCms.Models;
using Umbraco.Core.Models;
namespace LeafWeb.WebCms.Services
{
@@ -198,6 +197,11 @@ namespace LeafWeb.WebCms.Services
SendMessage(message);
}
public void SendVerifyMemberEmail(IMember member)
{
// TODO: write verify email to user
}
private string FormatWarningMessage(LeafInput leafInput)
{
if (leafInput.OutputWarningMessage != null)
+23 -8
View File
@@ -1,5 +1,6 @@
@using ClientDependency.Core.Mvc
@using LeafWeb.WebCms.Controllers
@using Umbraco.Web
@model LeafInputCreate
@{
Html.RequiresCss("~/backload/blueimp/bootstrap/BasicPlusUI/css");
@@ -9,15 +10,17 @@
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.min.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.custom.js", 2);
Html.RequiresJs("~/scripts/LeafInputCreate.js", 3);
var user = Membership.GetUser();
}
<div class="container-lg">
<div class="row">
<div class="col-md-12 card card-body bg-light">
<div class="col-md-8 card card-body bg-light">
@Html.Partial("_ValidationSummary")
<form id="fileupload" action="/Backload/FileHandler" method="POST" enctype="multipart/form-data">
<h4 class="card-title">Files</h4>
<div class="container-fluid fileupload-buttonbar">
<div class="row">
@@ -60,18 +63,30 @@
</div>
</form>
@using (Html.BeginUmbracoForm<LeafInputController>("Submit", null, new {id = "create"}))
@using (Html.BeginUmbracoForm<LeafInputController>("Submit", null, new { id = "create" }))
{
@Html.EditorFor(m => m.PhotosynthesisType)
@Html.EditorFor(m => m.Identifier)
@Html.EditorFor(m => m.SiteId)
@Html.EditorFor(m => m.Name)
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.EmailConfirm)
if (user == null)
{
@Html.EditorFor(m => m.Name)
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.EmailConfirm)
}
else
{
@Html.HiddenFor(m => m.Name)
@Html.HiddenFor(m => m.Email)
@Html.HiddenFor(m => m.EmailConfirm)
}
@Html.EditorFor(m => m.TermsOfService)
<input type="submit" id="submit-form" class="d-none"/>
<input type="submit" id="submit-form" class="d-none" />
}
<label for="submit-form" class="btn btn-primary pull-right">Submit...</label>
<div class="container"><div class="row">
<label for="submit-form" class="btn btn-primary col-6 offset-6 col-sm-5 offset-sm-7 col-md-4 offset-md-8">Submit...</label>
</div></div>
</div>
</div>
</div>
@@ -1,34 +1,27 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@{
var loginModel = new LoginModel { RedirectUrl = "/leaf-data/manage-queue/" };
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("~/scripts/jquery.validate.min.js");
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.min.js");
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.min.js");
}
<div class="container top-buffer">
<div class="row">
<div class="col-md-7 card card-body bg-light">
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-lg-4 card card-body bg-light">
@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
{
<fieldset>
@Html.ValidationSummary("loginModel", true)
<div class="form-group">
@Html.LabelFor(m => loginModel.Username)
@Html.TextBoxFor(m => loginModel.Username)
@Html.TextBoxFor(m => loginModel.Username, new {@class = "form-control" })
@Html.ValidationMessageFor(m => loginModel.Username)
</div>
<div class="form-group">
@Html.LabelFor(m => loginModel.Password)
@Html.PasswordFor(m => loginModel.Password)
@Html.PasswordFor(m => loginModel.Password, new {@class = "form-control" })
@Html.ValidationMessageFor(m => loginModel.Password)
</div>
@@ -0,0 +1,77 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using ClientDependency.Core.Mvc
@using Umbraco.Web.Controllers
<!-- https://24days.in/umbraco-cms/2015/membership-apis-investigation/ -->
<!-- https://our.umbraco.com/forum/templates-partial-views-and-macros/93133-membership-provider-registration-form -->
@{
var membershipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
var registerModel = membershipHelper.CreateRegistrationModel();
var success = TempData["FormSuccess"] != null;
Html.EnableClientValidation();
Html.RequiresJs("~/scripts/jquery.validate.min.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.min.js", 2);
Html.RequiresJs("~/scripts/Register.js");
}
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-lg-6 card card-body bg-light">
@if (success)
{
<p>Registration succeeded.</p>
}
else
{
using (Html.BeginUmbracoForm<UmbRegisterController>(
"HandleRegisterMember",
null,
new {id="register-member"}))
{
<div class="form-group">
@Html.ValidationSummary("registerModel", true)
@Html.LabelFor(m => registerModel.Name)
@Html.TextBoxFor(m => registerModel.Name, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Name)
</div>
<div class="form-group">
@Html.LabelFor(m => registerModel.Email)
@Html.TextBoxFor(m => registerModel.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Email)
</div>
<div class="form-group">
@Html.LabelFor(m => registerModel.Password)
@Html.PasswordFor(m => registerModel.Password, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Password)
</div>
<div class="form-group">
@Html.Label("VerifyPassword")
@Html.Password("VerifyPassword", null, new { @class = "form-control" })
@Html.ValidationMessage("VerifyPassword")
</div>
if (registerModel.MemberProperties != null)
{
for (var i = 0; i < registerModel.MemberProperties.Count; i++)
{
<div class="form-group">
@Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
@Html.EditorFor(m => registerModel.MemberProperties[i].Value, new { @class = "form-control" })
@Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
</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>
}
}
</div>
</div>
</div>
+1 -1
View File
@@ -11,7 +11,7 @@
}
else if (TempData.ContainsKey("LogoutSuccess") && (bool)TempData["LogoutSuccess"])
{
TempData["StatusMessage"] = "Logout sucessful";
TempData["StatusMessage"] = "Logout successful";
TempData["StatusMessage-Type"] = "alert-success";
}
Html.RequiresCss("~/Content/bootstrap_leafweb.css");
-6
View File
@@ -1,16 +1,10 @@
@inherits UmbracoTemplatePage
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@{
var loginStatusModel = Members.GetCurrentLoginStatus();
Html.RequiresJs("~/scripts/jquery.validate.min.js");
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.min.js");
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.min.js");
var logoutModel = new PostRedirectModel { RedirectUrl = "/" };
}
<div class="container">
+55 -47
View File
@@ -1,63 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host"
type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
<section name="pages"
type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.WebPages" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Optimization" />
<add namespace="WebGridBootstrapPager" />
<add namespace="LeafWeb.Core.Utility" />
<add namespace="LeafWeb.WebCms.Models" />
<add namespace="System.Web.Mvc" /><add namespace="System.Web.Mvc.Ajax" /><add namespace="System.Web.Mvc.Html" /><add namespace="System.Web.Routing" /><add namespace="Umbraco.Web" /><add namespace="Umbraco.Core" /><add namespace="Umbraco.Core.Models" /><add namespace="Umbraco.Web.Mvc" /><add namespace="umbraco" /><add namespace="Examine" /><add namespace="Umbraco.Web.PublishedContentModels" /></namespaces>
<add namespace="LeafWeb.Core.Utility" />
<add namespace="LeafWeb.WebCms.Models" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Umbraco.Web" />
<add namespace="Umbraco.Core" />
<add namespace="Umbraco.Core.Models" />
<add namespace="Umbraco.Web.Mvc" />
<add namespace="umbraco" />
<add namespace="Examine" />
<add namespace="Umbraco.Web.PublishedContentModels" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings><system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<host
factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<!--
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web><system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer></configuration>
<pages validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode"
type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
+5 -1
View File
@@ -37,7 +37,7 @@
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>2</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -895,6 +895,7 @@
<Content Include="scripts\popper-utils.min.js" />
<Content Include="scripts\popper.js" />
<Content Include="scripts\popper.min.js" />
<Content Include="scripts\Register.js" />
<Content Include="scripts\src\index.js" />
<Content Include="scripts\src\methods\defaults.js" />
<Content Include="scripts\src\methods\destroy.js" />
@@ -1060,6 +1061,7 @@
<Content Include="scripts\popper.js.map" />
<Content Include="scripts\popper-utils.min.js.map" />
<Content Include="scripts\popper-utils.js.map" />
<Content Include="Views\MacroPartials\Membership\Register.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -1095,6 +1097,7 @@
<Compile Include="Controllers\LeafWebPageIds.cs" />
<Compile Include="Controllers\QueueController.cs" />
<Compile Include="Controllers\ResultsController.cs" />
<Compile Include="EventHandlers\MemberRegistrationEventHandler.cs" />
<Compile Include="Models\ChartViewModel.cs" />
<Compile Include="Models\ContactForm.cs" />
<Compile Include="Models\LeafInputDetails.cs" />
@@ -1122,6 +1125,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Media\1051\" />
<Folder Include="Views\Register\" />
</ItemGroup>
<ItemGroup>
<Service Include="{4A0DDDB5-7A95-4FBF-97CC-616D07737A77}" />
+56
View File
@@ -0,0 +1,56 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines"/>
<pages pageBaseType="umbraco.MacroEngines.DynamicNodeContext">
<namespaces>
<add namespace="umbraco" />
<add namespace="Examine" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
+23
View File
@@ -0,0 +1,23 @@
$(function () {
$("#register-member").validate();
$('#VerifyPassword')
.rules("add",
{
required: true,
equalTo: "#registerModel_Password",
messages: {
required: "Verify Password is required",
equalTo: jQuery.validator.format("Passwords do not match")
}
}
);
$('#registerModel_Name')
.rules("add",
{
required: true,
messages: {
required: "Name is required"
}
}
);
});
+17 -3
View File
@@ -26,7 +26,7 @@
});
return false;
});
/*
// Making elements equal height
var equalheight = function(container){
@@ -109,7 +109,7 @@
$(this).toggleClass('selected');
}
}
});
}); */
$(".read-more")
.click(function () {
@@ -120,6 +120,20 @@
else
$(this).text("Show Less");
return false;
});
});
// https://stackoverflow.com/a/58215644/99492
$.validator.setDefaults({
errorClass: "",
validClass: "",
highlight: function (element, errorClass, validClass) {
$(element).addClass("is-invalid").removeClass("is-valid");
$(element.form).find("[data-valmsg-for=" + element.id + "]").addClass("invalid-feedback");
},
unhighlight: function (element, errorClass, validClass) {
$(element).addClass("is-valid").removeClass("is-invalid");
$(element.form).find("[data-valmsg-for=" + element.id + "]").removeClass("invalid-feedback");
}
});
})(jQuery);