diff --git a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityRole.cs b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityRole.cs
index 400fa49053..d595d0bb77 100644
--- a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityRole.cs
+++ b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityRole.cs
@@ -9,8 +9,6 @@ using Volo.ExtensionMethods.Collections.Generic;
namespace Volo.Abp.Identity
{
- //TODO: Properties should not be public!
-
///
/// Represents a role in the identity system
///
@@ -22,17 +20,17 @@ namespace Volo.Abp.Identity
///
/// Gets or sets the name for this role.
///
- public virtual string Name { get; set; }
+ public virtual string Name { get; protected internal set; }
///
/// Gets or sets the normalized name for this role.
///
- public virtual string NormalizedName { get; set; }
+ public virtual string NormalizedName { get; protected internal set; }
///
/// Navigation property for claims in this role.
///
- public virtual ICollection Claims { get; } = new Collection();
+ public virtual ICollection Claims { get; protected set; }
///
/// A random value that should change whenever a role is persisted to the store
@@ -56,6 +54,8 @@ namespace Volo.Abp.Identity
Id = id;
Name = name;
ConcurrencyStamp = Guid.NewGuid().ToString();
+
+ Claims = new Collection();
}
public void AddClaim([NotNull] IGuidGenerator guidGenerator, [NotNull] Claim claim)
diff --git a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs
index 0328f66e85..5b5ba94fcc 100644
--- a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs
+++ b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs
@@ -11,7 +11,6 @@ using Volo.ExtensionMethods.Collections.Generic;
namespace Volo.Abp.Identity
{
- //TODO: Properties should not be public!
//TODO: Add Name/Surname/FullName?
public class IdentityUser : AggregateRoot, IHasConcurrencyStamp
@@ -24,38 +23,38 @@ namespace Volo.Abp.Identity
///
/// Gets or sets the user name for this user.
///
- public virtual string UserName { get; set; }
+ public virtual string UserName { get; protected internal set; }
///
/// Gets or sets the normalized user name for this user.
///
- public virtual string NormalizedUserName { get; set; }
+ public virtual string NormalizedUserName { get; protected internal set; }
///
/// Gets or sets the email address for this user.
///
- public virtual string Email { get; set; }
+ public virtual string Email { get; protected internal set; }
///
/// Gets or sets the normalized email address for this user.
///
- public virtual string NormalizedEmail { get; set; }
+ public virtual string NormalizedEmail { get; protected internal set; }
///
/// Gets or sets a flag indicating if a user has confirmed their email address.
///
/// True if the email address has been confirmed, otherwise false.
- public virtual bool EmailConfirmed { get; set; }
+ public virtual bool EmailConfirmed { get; protected internal set; }
///
/// Gets or sets a salted and hashed representation of the password for this user.
///
- public virtual string PasswordHash { get; set; }
+ public virtual string PasswordHash { get; protected internal set; }
///
/// A random value that must change whenever a users credentials change (password changed, login removed)
///
- public virtual string SecurityStamp { get; set; }
+ public virtual string SecurityStamp { get; protected internal set; }
///
/// A random value that must change whenever a user is persisted to the store
@@ -65,19 +64,19 @@ namespace Volo.Abp.Identity
///
/// Gets or sets a telephone number for the user.
///
- public virtual string PhoneNumber { get; set; }
+ public virtual string PhoneNumber { get; protected internal set; }
///
/// Gets or sets a flag indicating if a user has confirmed their telephone address.
///
/// True if the telephone number has been confirmed, otherwise false.
- public virtual bool PhoneNumberConfirmed { get; set; }
+ public virtual bool PhoneNumberConfirmed { get; protected internal set; }
///
/// Gets or sets a flag indicating if two factor authentication is enabled for this user.
///
/// True if 2fa is enabled, otherwise false.
- public virtual bool TwoFactorEnabled { get; set; }
+ public virtual bool TwoFactorEnabled { get; protected internal set; }
///
/// Gets or sets the date and time, in UTC, when any user lockout ends.
@@ -85,40 +84,40 @@ namespace Volo.Abp.Identity
///
/// A value in the past means the user is not locked out.
///
- public virtual DateTimeOffset? LockoutEnd { get; set; }
+ public virtual DateTimeOffset? LockoutEnd { get; protected internal set; }
///
/// Gets or sets a flag indicating if the user could be locked out.
///
/// True if the user could be locked out, otherwise false.
- public virtual bool LockoutEnabled { get; set; }
+ public virtual bool LockoutEnabled { get; protected internal set; }
///
/// Gets or sets the number of failed login attempts for the current user.
///
- public virtual int AccessFailedCount { get; set; }
+ public virtual int AccessFailedCount { get; protected internal set; }
//TODO: Can we make collections readonly collection, which will provide encapsulation but can work for all ORMs?
///
/// Navigation property for the roles this user belongs to.
///
- public virtual ICollection Roles { get; } = new Collection();
+ public virtual ICollection Roles { get; protected set; }
///
/// Navigation property for the claims this user possesses.
///
- public virtual ICollection Claims { get; } = new Collection();
+ public virtual ICollection Claims { get; protected set; }
///
/// Navigation property for this users login accounts.
///
- public virtual ICollection Logins { get; } = new Collection();
+ public virtual ICollection Logins { get; protected set; }
///
/// Navigation property for this users tokens.
///
- public virtual ICollection Tokens { get; } = new Collection();
+ public virtual ICollection Tokens { get; protected set; }
protected IdentityUser()
{
@@ -132,6 +131,11 @@ namespace Volo.Abp.Identity
Id = id;
UserName = userName;
ConcurrencyStamp = Guid.NewGuid().ToString();
+
+ Roles = new Collection();
+ Claims = new Collection();
+ Logins = new Collection();
+ Tokens = new Collection();
}
public void AddRole(IGuidGenerator guidGenerator, Guid roleId)