mirror of
https://github.com/bitwarden/server
synced 2025-12-19 09:43:25 +00:00
* Adding the Secret manager to the Plan List * Adding the unit test for the StaticStoreTests class * Fix whitespace formatting * Fix whitespace formatting * Price update * Resolving the PR comments * Resolving PR comments * Fixing the whitespace * only password manager plans are return for now * format whitespace * Resolve the test issue * Fixing the failing test * Refactoring the Plan separation * add a unit test for SingleOrDefault * Fix the whitespace format * Separate the PM and SM plans * Fixing the whitespace * Remove unnecessary directive * Fix imports ordering * Fix imports ordering * Resolve imports ordering * Fixing imports ordering * Fix response model, add MaxProjects * Fix filename * Fix format * Fix: seat price should match annual/monthly * Fix service account annual pricing * Changes for secret manager signup and upgradeplan * Changes for secrets manager signup and upgrade * refactoring the code * Format whitespace * remove unnecessary using directive * Resolve the PR comment on Subscription creation * Resolve PR comment * Add password manager to the error message * Add UseSecretsManager to the event log * Resolve PR comment on plan validation * Resolving pr comments for service account count * Resolving pr comments for service account count * Resolve the pr comments * Remove the store procedure that is no-longer needed * Rename a property properly * Resolving the PR comment * Resolve PR comments * Resolving PR comments * Resolving the Pr comments * Resolving some PR comments * Resolving the PR comments * Resolving the build identity build * Add additional Validation * Resolve the Lint issues * remove unnecessary using directive * Remove the white spaces * Adding unit test for the stripe payment * Remove the incomplete test * Fixing the failing test * Fix the failing test * Fix the fail test on organization service * Fix the failing unit test * Fix the whitespace format * Fix the failing test * Fix the whitespace format * resolve pr comments * Fix the lint message * Resolve the PR comments * resolve pr comments * Resolve pr comments * Resolve the pr comments * remove unused code * Added for sm validation test * Fix the whitespace format issues --------- Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
111 lines
4.2 KiB
C#
111 lines
4.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Business;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Api.Models.Request.Organizations;
|
|
|
|
public class OrganizationCreateRequestModel : IValidatableObject
|
|
{
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string Name { get; set; }
|
|
[StringLength(50)]
|
|
public string BusinessName { get; set; }
|
|
[Required]
|
|
[StringLength(256)]
|
|
[EmailAddress]
|
|
public string BillingEmail { get; set; }
|
|
public PlanType PlanType { get; set; }
|
|
[Required]
|
|
public string Key { get; set; }
|
|
public OrganizationKeysRequestModel Keys { get; set; }
|
|
public PaymentMethodType? PaymentMethodType { get; set; }
|
|
public string PaymentToken { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int AdditionalSeats { get; set; }
|
|
[Range(0, 99)]
|
|
public short? AdditionalStorageGb { get; set; }
|
|
public bool PremiumAccessAddon { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(1000)]
|
|
public string CollectionName { get; set; }
|
|
public string TaxIdNumber { get; set; }
|
|
public string BillingAddressLine1 { get; set; }
|
|
public string BillingAddressLine2 { get; set; }
|
|
public string BillingAddressCity { get; set; }
|
|
public string BillingAddressState { get; set; }
|
|
public string BillingAddressPostalCode { get; set; }
|
|
[StringLength(2)]
|
|
public string BillingAddressCountry { get; set; }
|
|
public int? MaxAutoscaleSeats { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int? AdditionalSmSeats { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int? AdditionalServiceAccounts { get; set; }
|
|
[Required]
|
|
public bool UseSecretsManager { get; set; }
|
|
|
|
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
|
{
|
|
var orgSignup = new OrganizationSignup
|
|
{
|
|
Owner = user,
|
|
OwnerKey = Key,
|
|
Name = Name,
|
|
Plan = PlanType,
|
|
PaymentMethodType = PaymentMethodType,
|
|
PaymentToken = PaymentToken,
|
|
AdditionalSeats = AdditionalSeats,
|
|
MaxAutoscaleSeats = MaxAutoscaleSeats,
|
|
AdditionalStorageGb = AdditionalStorageGb.GetValueOrDefault(0),
|
|
PremiumAccessAddon = PremiumAccessAddon,
|
|
BillingEmail = BillingEmail,
|
|
BusinessName = BusinessName,
|
|
CollectionName = CollectionName,
|
|
AdditionalSmSeats = AdditionalSmSeats.GetValueOrDefault(),
|
|
AdditionalServiceAccounts = AdditionalServiceAccounts.GetValueOrDefault(),
|
|
UseSecretsManager = UseSecretsManager,
|
|
TaxInfo = new TaxInfo
|
|
{
|
|
TaxIdNumber = TaxIdNumber,
|
|
BillingAddressLine1 = BillingAddressLine1,
|
|
BillingAddressLine2 = BillingAddressLine2,
|
|
BillingAddressCity = BillingAddressCity,
|
|
BillingAddressState = BillingAddressState,
|
|
BillingAddressPostalCode = BillingAddressPostalCode,
|
|
BillingAddressCountry = BillingAddressCountry,
|
|
},
|
|
};
|
|
|
|
Keys?.ToOrganizationSignup(orgSignup);
|
|
|
|
return orgSignup;
|
|
}
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(PaymentToken))
|
|
{
|
|
yield return new ValidationResult("Payment required.", new string[] { nameof(PaymentToken) });
|
|
}
|
|
if (PlanType != PlanType.Free && !PaymentMethodType.HasValue)
|
|
{
|
|
yield return new ValidationResult("Payment method type required.",
|
|
new string[] { nameof(PaymentMethodType) });
|
|
}
|
|
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(BillingAddressCountry))
|
|
{
|
|
yield return new ValidationResult("Country required.",
|
|
new string[] { nameof(BillingAddressCountry) });
|
|
}
|
|
if (PlanType != PlanType.Free && BillingAddressCountry == "US" &&
|
|
string.IsNullOrWhiteSpace(BillingAddressPostalCode))
|
|
{
|
|
yield return new ValidationResult("Zip / postal code is required.",
|
|
new string[] { nameof(BillingAddressPostalCode) });
|
|
}
|
|
}
|
|
}
|