Fixes: U4-5207 User Type with a space in the name breaks User Content
This commit is contained in:
@@ -1,27 +1,55 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using Umbraco.Core.Models.EntityBase;
|
using Umbraco.Core.Models.EntityBase;
|
||||||
using Umbraco.Core.Persistence.Mappers;
|
using Umbraco.Core.Persistence.Mappers;
|
||||||
|
using Umbraco.Core.Strings;
|
||||||
|
|
||||||
namespace Umbraco.Core.Models.Membership
|
namespace Umbraco.Core.Models.Membership
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the Type for a Backoffice User
|
/// Represents the Type for a Backoffice User
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// Should be internal until a proper user/membership implementation
|
|
||||||
/// is part of the roadmap.
|
|
||||||
/// </remarks>
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[DataContract(IsReference = true)]
|
[DataContract(IsReference = true)]
|
||||||
internal class UserType : Entity, IUserType
|
internal class UserType : Entity, IUserType
|
||||||
{
|
{
|
||||||
[DataMember]
|
private string _alias;
|
||||||
public string Alias { get; set; }
|
private string _name;
|
||||||
|
private IEnumerable<string> _permissions;
|
||||||
|
|
||||||
|
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<UserType, string>(x => x.Name);
|
||||||
|
private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo<UserType, string>(x => x.Alias);
|
||||||
|
private static readonly PropertyInfo PermissionsSelector = ExpressionHelper.GetPropertyInfo<UserType, IEnumerable<string>>(x => x.Permissions);
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string Name { get; set; }
|
public string Alias
|
||||||
|
{
|
||||||
|
get { return _alias; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetPropertyValueAndDetectChanges(o =>
|
||||||
|
{
|
||||||
|
_alias = value.ToCleanString(CleanStringType.Alias | CleanStringType.UmbracoCase);
|
||||||
|
return _alias;
|
||||||
|
}, _alias, AliasSelector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _name; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetPropertyValueAndDetectChanges(o =>
|
||||||
|
{
|
||||||
|
_name = value;
|
||||||
|
return _name;
|
||||||
|
}, _name, NameSelector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The set of default permissions for the user type
|
/// The set of default permissions for the user type
|
||||||
@@ -30,6 +58,17 @@ namespace Umbraco.Core.Models.Membership
|
|||||||
/// By default each permission is simply a single char but we've made this an enumerable{string} to support a more flexible permissions structure in the future.
|
/// By default each permission is simply a single char but we've made this an enumerable{string} to support a more flexible permissions structure in the future.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public IEnumerable<string> Permissions { get; set; }
|
public IEnumerable<string> Permissions
|
||||||
|
{
|
||||||
|
get { return _permissions; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetPropertyValueAndDetectChanges(o =>
|
||||||
|
{
|
||||||
|
_permissions = value;
|
||||||
|
return _permissions;
|
||||||
|
}, _permissions, PermissionsSelector);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user