1
0
mirror of https://github.com/bitwarden/server synced 2025-12-19 17:53:44 +00:00

refactor to a new two-factor controller

This commit is contained in:
Kyle Spearrin
2017-06-19 22:08:10 -04:00
parent 5a67df60de
commit 3b5b24531b
14 changed files with 411 additions and 152 deletions

View File

@@ -1,18 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Api
{
public class RecoverTwoFactorRequestModel
{
[Required]
[EmailAddress]
[StringLength(50)]
public string Email { get; set; }
[Required]
public string MasterPasswordHash { get; set; }
[Required]
[StringLength(32)]
public string RecoveryCode { get; set; }
}
}

View File

@@ -1,16 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Api
{
public class UpdateTwoFactorRequestModel
{
[Required]
public string MasterPasswordHash { get; set; }
[Required]
public bool? Enabled { get; set; }
[Required]
[StringLength(50)]
public string Token { get; set; }
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Api
{
public class UpdateTwoFactorAuthenticatorRequestModel : TwoFactorRequestModel
{
[Required]
[StringLength(50)]
public string Token { get; set; }
}
public class UpdateTwoFactorDuoRequestModel : TwoFactorRequestModel
{
[Required]
[StringLength(50)]
public string IntegrationKey { get; set; }
[Required]
[StringLength(50)]
public string SecretKey { get; set; }
[Required]
[StringLength(50)]
public string Host { get; set; }
}
public class UpdateTwoFactorYubicoOtpRequestModel : TwoFactorRequestModel, IValidatableObject
{
public string Key1 { get; set; }
public string Key2 { get; set; }
public string Key3 { get; set; }
public string Key4 { get; set; }
public string Key5 { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(Key1) && string.IsNullOrWhiteSpace(Key2) && string.IsNullOrWhiteSpace(Key3) &&
string.IsNullOrWhiteSpace(Key4) && string.IsNullOrWhiteSpace(Key5))
{
yield return new ValidationResult("A Key is required.", new string[] { nameof(Key1) });
}
}
}
public class UpdateTwoFactorEmailRequestModel : TwoFactorRequestModel
{
[Required]
[EmailAddress]
[StringLength(50)]
public string Email { get; set; }
[Required]
[StringLength(50)]
public string Token { get; set; }
}
public class TwoFactorProviderRequestModel : TwoFactorRequestModel
{
[Required]
public Enums.TwoFactorProviderType? Type { get; set; }
}
public class TwoFactorRequestModel
{
[Required]
public string MasterPasswordHash { get; set; }
}
public class TwoFactorRecoveryRequestModel
{
[Required]
[EmailAddress]
[StringLength(50)]
public string Email { get; set; }
[Required]
public string MasterPasswordHash { get; set; }
[Required]
[StringLength(32)]
public string RecoveryCode { get; set; }
}
}