IwbSysUser.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. [Required]
  30. [StringLength(MaxEmailAddressLength)]
  31. public virtual string NormalizedEmailAddress { get; set; }
  32. /// <summary>
  33. /// A random value that must change whenever a user is persisted to the store
  34. /// </summary>
  35. [StringLength(MaxConcurrencyStampLength)]
  36. public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString();
  37. // public virtual ICollection<UserToken> Tokens { get; set; }
  38. public virtual TUser DeleterUser { get; set; }
  39. public virtual TUser CreatorUser { get; set; }
  40. public virtual TUser LastModifierUser { get; set; }
  41. public virtual void SetNormalizedNames()
  42. {
  43. NormalizedUserName = UserName?.ToUpperInvariant();
  44. NormalizedEmailAddress = EmailAddress?.ToUpperInvariant();
  45. }
  46. }
  47. }