1
0
mirror of https://github.com/bitwarden/server synced 2025-12-15 07:43:54 +00:00

tool to generate licenses (#874)

* tool to generate licenses

* code review feedback
This commit is contained in:
Kyle Spearrin
2020-08-18 17:00:21 -04:00
committed by GitHub
parent c65c52d997
commit 2872bda6fe
10 changed files with 185 additions and 13 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Bit.Admin.Models
{
public class LicenseModel : IValidatableObject
{
[Display(Name = "User Id")]
public Guid? UserId { get; set; }
[Display(Name = "Organization Id")]
public Guid? OrganizationId { get; set; }
[Display(Name = "Installation Id")]
public Guid? InstallationId { get; set; }
[Required]
[Display(Name = "Version")]
public int Version { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (UserId.HasValue && OrganizationId.HasValue)
{
yield return new ValidationResult("Use either User Id or Organization Id. Not both.");
}
if (!UserId.HasValue && !OrganizationId.HasValue)
{
yield return new ValidationResult("User Id or Organization Id is required.");
}
if (OrganizationId.HasValue && !InstallationId.HasValue)
{
yield return new ValidationResult("Installation Id is required for organization licenses.");
}
}
}
}