1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

premium signup with license file

This commit is contained in:
Kyle Spearrin
2017-08-11 17:06:31 -04:00
parent 02bb037e38
commit 73029f76d2
15 changed files with 125 additions and 42 deletions

View File

@ -1,10 +1,28 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
namespace Bit.Core.Models.Api
{
public class PremiumRequestModel : PaymentRequestModel
public class PremiumRequestModel : IValidatableObject
{
public string PaymentToken { get; set; }
[Range(0, 99)]
public short? AdditionalStorageGb { get; set; }
public IFormFile License { get; set; }
public bool Validate(GlobalSettings globalSettings)
{
return (License == null && !globalSettings.SelfHosted) ||
(License != null && globalSettings.SelfHosted);
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(PaymentToken) && License == null)
{
yield return new ValidationResult("Payment token or license is required.");
}
}
}
}