* InputUserName.cs:
* WebControls.csproj: * Estimate.aspx: UserName input control * IValueProvider.cs: * TemplateException.cs: * ResultPages.cs: code cleanning * WorkFlowController.cs: Admin now can register new users * LocalizedText.resx: * LocalizedText.Designer.cs: new registration messages * RegisterModel.cs: The registration message contains the user validation decision
This commit is contained in:
parent
c943606b43
commit
cce43b9daf
10 changed files with 228 additions and 6 deletions
|
|
@ -9,6 +9,9 @@ using Yavsc.Model.WorkFlow;
|
|||
using System.Web.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Model;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
@ -51,6 +54,45 @@ namespace Yavsc.ApiControllers
|
|||
Membership.GetUser().UserName,client,title,description);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified model and isapprouved.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
/// <param name="isapprouved">If set to <c>true</c> isapprouved.</param>
|
||||
[HttpGet]
|
||||
[ValidateAjax]
|
||||
[Authorize(Roles="Admin,FrontOffice")]
|
||||
public void Register([FromBody] RegisterModel model)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
MembershipCreateStatus mcs;
|
||||
var user = Membership.CreateUser (
|
||||
model.UserName,
|
||||
model.Password,
|
||||
model.Email,
|
||||
null,
|
||||
null,
|
||||
model.IsApprouved,
|
||||
out mcs);
|
||||
switch (mcs) {
|
||||
case MembershipCreateStatus.DuplicateEmail:
|
||||
ModelState.AddModelError ("Email",
|
||||
string.Format(LocalizedText.DuplicateEmail,model.UserName) );
|
||||
return ;
|
||||
case MembershipCreateStatus.DuplicateUserName:
|
||||
ModelState.AddModelError ("UserName",
|
||||
string.Format(LocalizedText.DuplicateUserName,model.Email));
|
||||
return ;
|
||||
case MembershipCreateStatus.Success:
|
||||
if (!model.IsApprouved)
|
||||
YavscHelpers.SendActivationEmail (user);
|
||||
return;
|
||||
default:
|
||||
throw new InvalidOperationException (string.Format("Unexpected user creation code :{0}",mcs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops the writting.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Yavsc;
|
||||
using SalesCatalog;
|
||||
using System.Web.Routing;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Yavsc;
|
||||
using SalesCatalog;
|
||||
using System.Web.Routing;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<%@ Page Title="Devis" Language="C#" Inherits="System.Web.Mvc.ViewPage<Estimate>" MasterPageFile="~/Models/App.master" %>
|
||||
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" ID="head1" runat="server" >
|
||||
<script type="text/javascript" src="<%=Url.Content("~/Scripts/stupidtable.js")%>"></script>
|
||||
|
|
@ -18,7 +19,12 @@ $("#tbwrts").stupidtable();
|
|||
<%= Html.ValidationMessage("Title", "*") %>
|
||||
<br/>
|
||||
<%= Html.Hidden ("Responsible") %>
|
||||
<%= Html.LabelFor(model => model.Client) %>:<%=Html.TextBox( "Client" ) %>
|
||||
|
||||
<%= Html.LabelFor(model => model.Client) %>:
|
||||
<% Client.Value = Model.Client ; %>
|
||||
<yavsc:InputUserName id="Client" name="Client" runat="server">
|
||||
</yavsc:InputUserName>
|
||||
|
||||
<%= Html.ValidationMessage("Client", "*") %>
|
||||
<br/>
|
||||
<%= Html.LabelFor(model => model.Description) %>:<%=Html.TextArea( "Description") %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue