2020-12-16 20:36:47 +01:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2021-08-31 13:49:11 +10:00
|
|
|
|
using Bit.Core.Utilities;
|
2020-12-16 20:36:47 +01:00
|
|
|
|
using Bit.Core.Models.Table;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Models.Api.Request
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EmergencyAccessInviteRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
2021-08-31 13:49:11 +10:00
|
|
|
|
[StrictEmailAddress]
|
2021-03-25 19:21:23 +01:00
|
|
|
|
[StringLength(256)]
|
2020-12-16 20:36:47 +01:00
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public Enums.EmergencyAccessType? Type { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public int WaitTimeDays { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EmergencyAccessUpdateRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public Enums.EmergencyAccessType Type { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public int WaitTimeDays { get; set; }
|
|
|
|
|
|
public string KeyEncrypted { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public EmergencyAccess ToEmergencyAccess(EmergencyAccess existingEmergencyAccess)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ensure we only set keys for a confirmed emergency access.
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(existingEmergencyAccess.KeyEncrypted) && !string.IsNullOrWhiteSpace(KeyEncrypted))
|
|
|
|
|
|
{
|
|
|
|
|
|
existingEmergencyAccess.KeyEncrypted = KeyEncrypted;
|
|
|
|
|
|
}
|
|
|
|
|
|
existingEmergencyAccess.Type = Type;
|
|
|
|
|
|
existingEmergencyAccess.WaitTimeDays = WaitTimeDays;
|
|
|
|
|
|
return existingEmergencyAccess;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EmergencyAccessPasswordRequestModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
[StringLength(300)]
|
|
|
|
|
|
public string NewMasterPasswordHash { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|