IwbSysUser.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using Abp.Domain.Entities.Auditing;
  4. using IwbZero.Authorization.Base.Users;
  5. using Microsoft.AspNet.Identity;
  6. namespace IwbZero.Authorization.Users
  7. {
  8. /// <summary>
  9. /// Represents a user.
  10. /// </summary>
  11. public abstract class IwbSysUser<TUser> : UserBase, IUser<long>, IFullAudited<TUser>
  12. where TUser : IwbSysUser<TUser>
  13. {
  14. /// <summary>
  15. /// Maximum length of the <see cref="ConcurrencyStamp"/> property.
  16. /// </summary>
  17. public const int MaxConcurrencyStampLength = 128;
  18. /// <summary>
  19. /// User name.
  20. /// User name must be unique for it's tenant.
  21. /// </summary>
  22. [Required]
  23. [StringLength(MaxUserNameLength)]
  24. public virtual string NormalizedUserName { get; set; }
  25. /// <summary>
  26. /// Email address of the user.
  27. /// Email address must be unique for it's tenant.
  28. /// </summary>
  29. [StringLength(MaxEmailAddressLength)]
  30. public virtual string NormalizedEmailAddress { get; set; }
  31. /// <summary>
  32. /// A random value that must change whenever a user is persisted to the store
  33. /// </summary>
  34. [StringLength(MaxConcurrencyStampLength)]
  35. public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString();
  36. // public virtual ICollection<UserToken> Tokens { get; set; }
  37. public virtual TUser DeleterUser { get; set; }
  38. public virtual TUser CreatorUser { get; set; }
  39. public virtual TUser LastModifierUser { get; set; }
  40. public virtual void SetNormalizedNames()
  41. {
  42. NormalizedUserName = UserName?.ToUpperInvariant();
  43. NormalizedEmailAddress = EmailAddress?.ToUpperInvariant();
  44. }
  45. }
  46. }