User.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. public partial class User
  8. {
  9. partial void Init();
  10. /// <summary>
  11. /// Default constructor. Protected due to required properties, but present because EF needs it.
  12. /// </summary>
  13. protected User()
  14. {
  15. Groups = new HashSet<Group>();
  16. Permissions = new HashSet<Permission>();
  17. ProviderMappings = new HashSet<ProviderMapping>();
  18. Preferences = new HashSet<Preference>();
  19. Init();
  20. }
  21. /// <summary>
  22. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  23. /// </summary>
  24. public static User CreateUserUnsafe()
  25. {
  26. return new User();
  27. }
  28. /// <summary>
  29. /// Public constructor with required data
  30. /// </summary>
  31. /// <param name="username"></param>
  32. /// <param name="mustupdatepassword"></param>
  33. /// <param name="audiolanguagepreference"></param>
  34. /// <param name="authenticationproviderid"></param>
  35. /// <param name="invalidloginattemptcount"></param>
  36. /// <param name="subtitlemode"></param>
  37. /// <param name="playdefaultaudiotrack"></param>
  38. public User(string username, bool mustupdatepassword, string audiolanguagepreference, string authenticationproviderid, int invalidloginattemptcount, string subtitlemode, bool playdefaultaudiotrack)
  39. {
  40. if (string.IsNullOrEmpty(username)) throw new ArgumentNullException(nameof(username));
  41. this.Username = username;
  42. this.MustUpdatePassword = mustupdatepassword;
  43. if (string.IsNullOrEmpty(audiolanguagepreference)) throw new ArgumentNullException(nameof(audiolanguagepreference));
  44. this.AudioLanguagePreference = audiolanguagepreference;
  45. if (string.IsNullOrEmpty(authenticationproviderid)) throw new ArgumentNullException(nameof(authenticationproviderid));
  46. this.AuthenticationProviderId = authenticationproviderid;
  47. this.InvalidLoginAttemptCount = invalidloginattemptcount;
  48. if (string.IsNullOrEmpty(subtitlemode)) throw new ArgumentNullException(nameof(subtitlemode));
  49. this.SubtitleMode = subtitlemode;
  50. this.PlayDefaultAudioTrack = playdefaultaudiotrack;
  51. this.Groups = new HashSet<Group>();
  52. this.Permissions = new HashSet<Permission>();
  53. this.ProviderMappings = new HashSet<ProviderMapping>();
  54. this.Preferences = new HashSet<Preference>();
  55. Init();
  56. }
  57. /// <summary>
  58. /// Static create function (for use in LINQ queries, etc.)
  59. /// </summary>
  60. /// <param name="username"></param>
  61. /// <param name="mustupdatepassword"></param>
  62. /// <param name="audiolanguagepreference"></param>
  63. /// <param name="authenticationproviderid"></param>
  64. /// <param name="invalidloginattemptcount"></param>
  65. /// <param name="subtitlemode"></param>
  66. /// <param name="playdefaultaudiotrack"></param>
  67. public static User Create(string username, bool mustupdatepassword, string audiolanguagepreference, string authenticationproviderid, int invalidloginattemptcount, string subtitlemode, bool playdefaultaudiotrack)
  68. {
  69. return new User(username, mustupdatepassword, audiolanguagepreference, authenticationproviderid, invalidloginattemptcount, subtitlemode, playdefaultaudiotrack);
  70. }
  71. /*************************************************************************
  72. * Properties
  73. *************************************************************************/
  74. /// <summary>
  75. /// Identity, Indexed, Required
  76. /// </summary>
  77. [Key]
  78. [Required]
  79. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  80. public int Id { get; protected set; }
  81. /// <summary>
  82. /// Required, Max length = 255
  83. /// </summary>
  84. [Required]
  85. [MaxLength(255)]
  86. [StringLength(255)]
  87. public string Username { get; set; }
  88. /// <summary>
  89. /// Max length = 65535
  90. /// </summary>
  91. [MaxLength(65535)]
  92. [StringLength(65535)]
  93. public string Password { get; set; }
  94. /// <summary>
  95. /// Required
  96. /// </summary>
  97. [Required]
  98. public bool MustUpdatePassword { get; set; }
  99. /// <summary>
  100. /// Required, Max length = 255
  101. /// </summary>
  102. [Required]
  103. [MaxLength(255)]
  104. [StringLength(255)]
  105. public string AudioLanguagePreference { get; set; }
  106. /// <summary>
  107. /// Required, Max length = 255
  108. /// </summary>
  109. [Required]
  110. [MaxLength(255)]
  111. [StringLength(255)]
  112. public string AuthenticationProviderId { get; set; }
  113. /// <summary>
  114. /// Max length = 65535
  115. /// </summary>
  116. [MaxLength(65535)]
  117. [StringLength(65535)]
  118. public string GroupedFolders { get; set; }
  119. /// <summary>
  120. /// Required
  121. /// </summary>
  122. [Required]
  123. public int InvalidLoginAttemptCount { get; set; }
  124. /// <summary>
  125. /// Max length = 65535
  126. /// </summary>
  127. [MaxLength(65535)]
  128. [StringLength(65535)]
  129. public string LatestItemExcludes { get; set; }
  130. public int? LoginAttemptsBeforeLockout { get; set; }
  131. /// <summary>
  132. /// Max length = 65535
  133. /// </summary>
  134. [MaxLength(65535)]
  135. [StringLength(65535)]
  136. public string MyMediaExcludes { get; set; }
  137. /// <summary>
  138. /// Max length = 65535
  139. /// </summary>
  140. [MaxLength(65535)]
  141. [StringLength(65535)]
  142. public string OrderedViews { get; set; }
  143. /// <summary>
  144. /// Required, Max length = 255
  145. /// </summary>
  146. [Required]
  147. [MaxLength(255)]
  148. [StringLength(255)]
  149. public string SubtitleMode { get; set; }
  150. /// <summary>
  151. /// Required
  152. /// </summary>
  153. [Required]
  154. public bool PlayDefaultAudioTrack { get; set; }
  155. /// <summary>
  156. /// Max length = 255
  157. /// </summary>
  158. [MaxLength(255)]
  159. [StringLength(255)]
  160. public string SubtitleLanguagePrefernce { get; set; }
  161. public bool? DisplayMissingEpisodes { get; set; }
  162. public bool? DisplayCollectionsView { get; set; }
  163. public bool? HidePlayedInLatest { get; set; }
  164. public bool? RememberAudioSelections { get; set; }
  165. public bool? RememberSubtitleSelections { get; set; }
  166. public bool? EnableNextEpisodeAutoPlay { get; set; }
  167. public bool? EnableUserPreferenceAccess { get; set; }
  168. /// <summary>
  169. /// Required, ConcurrenyToken
  170. /// </summary>
  171. [ConcurrencyCheck]
  172. [Required]
  173. public uint RowVersion { get; set; }
  174. public void OnSavingChanges()
  175. {
  176. RowVersion++;
  177. }
  178. /*************************************************************************
  179. * Navigation properties
  180. *************************************************************************/
  181. [ForeignKey("Group_Groups_Id")]
  182. public virtual ICollection<Group> Groups { get; protected set; }
  183. [ForeignKey("Permission_Permissions_Id")]
  184. public virtual ICollection<Permission> Permissions { get; protected set; }
  185. [ForeignKey("ProviderMapping_ProviderMappings_Id")]
  186. public virtual ICollection<ProviderMapping> ProviderMappings { get; protected set; }
  187. [ForeignKey("Preference_Preferences_Id")]
  188. public virtual ICollection<Preference> Preferences { get; protected set; }
  189. }
  190. }