UserLoginLog.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Abp.Domain.Entities;
  5. using Abp.Domain.Entities.Auditing;
  6. using Abp.Timing;
  7. namespace IwbZero.Authorization.Users
  8. {/// <summary>
  9. /// Used to save a login attempt of a user.
  10. /// </summary>
  11. [Table("Sys_UserLoginLogs")]
  12. public class UserLoginAttempt : Entity<long>, IHasCreationTime
  13. {
  14. public const int MaxUserNameOrEmailAddressLength = 255;
  15. /// <summary>
  16. /// Maximum length of <see cref="ClientIpAddress"/> property.
  17. /// </summary>
  18. public const int MaxClientIpAddressLength = 64;
  19. /// <summary>
  20. /// Maximum length of <see cref="ClientName"/> property.
  21. /// </summary>
  22. public const int MaxClientNameLength = 128;
  23. /// <summary>
  24. /// Maximum length of <see cref="BrowserInfo"/> property.
  25. /// </summary>
  26. public const int MaxBrowserInfoLength = 512;
  27. /// <summary>
  28. /// User's Id, if <see cref="UserNameOrEmailAddress"/> was a valid username or email address.
  29. /// </summary>
  30. public long? UserId { get; set; }
  31. /// <summary>
  32. /// User name or email address
  33. /// </summary>
  34. [MaxLength(MaxUserNameOrEmailAddressLength)]
  35. public string UserNameOrEmailAddress { get; set; }
  36. /// <summary>
  37. /// IP address of the client.
  38. /// </summary>
  39. [MaxLength(MaxClientIpAddressLength)]
  40. public string ClientIpAddress { get; set; }
  41. /// <summary>
  42. /// Name (generally computer name) of the client.
  43. /// </summary>
  44. [MaxLength(MaxClientNameLength)]
  45. public string ClientName { get; set; }
  46. /// <summary>
  47. /// Browser information if this method is called in a web request.
  48. /// </summary>
  49. [MaxLength(MaxBrowserInfoLength)]
  50. public string BrowserInfo { get; set; }
  51. /// <summary>
  52. /// Login attempt result.
  53. /// </summary>
  54. public AbpLoginResultType Result { get; set; }
  55. public DateTime CreationTime { get; set; }
  56. /// <summary>
  57. /// Initializes a new instance of the <see cref="UserLoginAttempt"/> class.
  58. /// </summary>
  59. public UserLoginAttempt()
  60. {
  61. CreationTime = Clock.Now;
  62. }
  63. }
  64. }