Files
server/src/Core/Models/Api/Public/MemberBaseModel.cs

63 lines
2.0 KiB
C#
Raw Normal View History

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