Moved controllers and models as per Shannon's suggestion

Added LoginStatus and updated Register
Updated to use CDF instead of <script> tags
This commit is contained in:
Sebastiaan Janssen
2013-08-28 13:36:04 +02:00
parent 8274883fa5
commit f26d759c84
14 changed files with 183 additions and 86 deletions

View File

@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using umbraco.cms.businesslogic.member;
using Umbraco.Core;
namespace Umbraco.Web.Models
{
public class RegisterModel
{
[Required]
[RegularExpression(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
ErrorMessage = "Please enter a valid e-mail address")]
public string Email { get; set; }
[Required]
public string Password { get; set; }
public string MemberTypeAlias { get; set; }
public List<UmbracoProperty> MemberProperties { get; set; }
public void FillModel(RegisterModel registerModel, IDictionary<string, object> macroParameters)
{
registerModel.MemberTypeAlias = macroParameters.GetValueAsString("memberTypeAlias", "UmbracoMember");
registerModel.MemberProperties = new List<UmbracoProperty>();
var memberType = MemberType.GetByAlias(registerModel.MemberTypeAlias);
var memberTypeProperties = memberType.PropertyTypes.ToList();
if (memberTypeProperties.Where(memberType.MemberCanEdit).Any())
{
memberTypeProperties = memberTypeProperties.Where(memberType.MemberCanEdit).ToList();
}
foreach (var prop in memberTypeProperties)
{
registerModel.MemberProperties.Add(new UmbracoProperty { Alias = prop.Alias, Name = prop.Name, Value = string.Empty });
}
}
}
public class UmbracoProperty
{
public string Alias { get; set; }
public string Value { get; set; }
public string Name { get; set; }
}
}