* 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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue