using System; using System.ComponentModel.DataAnnotations; using Bit.Core.Enums; using Bit.Core.Models.Data; using Bit.Core.Models.Table; namespace Bit.Api.Models.Public { public abstract class MemberBaseModel { public MemberBaseModel() { } public MemberBaseModel(OrganizationUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } Type = user.Type; AccessAll = user.AccessAll; ExternalId = user.ExternalId; ResetPasswordEnrolled = user.ResetPasswordKey != null; } public MemberBaseModel(OrganizationUserUserDetails user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } Type = user.Type; AccessAll = user.AccessAll; ExternalId = user.ExternalId; ResetPasswordEnrolled = user.ResetPasswordKey != null; } /// /// The member's type (or role) within the organization. /// [Required] public OrganizationUserType? Type { get; set; } /// /// Determines if this member can access all collections within the organization, or only the associated /// collections. If set to true, this option overrides any collection assignments. /// [Required] public bool? AccessAll { get; set; } /// /// External identifier for reference or linking this member to another system, such as a user directory. /// /// external_id_123456 [StringLength(300)] public string ExternalId { get; set; } /// /// Returns true if the member has enrolled in Password Reset assistance within the organization /// [Required] public bool ResetPasswordEnrolled { get; set; } } }