mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 13:08:17 -05:00
[AC-1360] Add logic to automatically populate the reseller name field (#3149)
* [AC-1360] Added Name field to view for creating a Reseller Provider * [AC-1360] Added migration script to populate existing Reseller Provider names with value from BusinessName * [AC-1360] Added fallback when retrieving display attribute name value * [AC-1360] Added EF scripts for MySQL, Postgres and Sqlite * [AC-1360] Added EF migration scripts * [AC-1360] Changed down migrator methods to empty * Revert "[AC-1360] Changed down migrator methods to empty" This reverts commit 0e72c14d2fad011d4be002a765682446e65de79c. * Revert "[AC-1360] Added EF migration scripts" This reverts commit a4ea5c4dca2e2fef2f678c21188531c54da0d3ea. * Revert "[AC-1360] Added EF scripts for MySQL, Postgres and Sqlite" This reverts commit 4b47d257556b5059167cbc58f6c624158783aae4. * [AC-1360] Moved data migration file do data migration folder
This commit is contained in:
parent
c479fe3f94
commit
222d57622e
@ -15,6 +15,9 @@ public class CreateProviderModel : IValidatableObject
|
||||
[Display(Name = "Owner Email")]
|
||||
public string OwnerEmail { get; set; }
|
||||
|
||||
[Display(Name = "Name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "Business Name")]
|
||||
public string BusinessName { get; set; }
|
||||
|
||||
@ -26,6 +29,7 @@ public class CreateProviderModel : IValidatableObject
|
||||
return new Provider()
|
||||
{
|
||||
Type = Type,
|
||||
Name = Name,
|
||||
BusinessName = BusinessName,
|
||||
BillingEmail = BillingEmail?.ToLowerInvariant().Trim()
|
||||
};
|
||||
@ -38,19 +42,24 @@ public class CreateProviderModel : IValidatableObject
|
||||
case ProviderType.Msp:
|
||||
if (string.IsNullOrWhiteSpace(OwnerEmail))
|
||||
{
|
||||
var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute<CreateProviderModel>()?.GetName();
|
||||
var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute<CreateProviderModel>()?.GetName() ?? nameof(OwnerEmail);
|
||||
yield return new ValidationResult($"The {ownerEmailDisplayName} field is required.");
|
||||
}
|
||||
break;
|
||||
case ProviderType.Reseller:
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
var nameDisplayName = nameof(Name).GetDisplayAttribute<CreateProviderModel>()?.GetName() ?? nameof(Name);
|
||||
yield return new ValidationResult($"The {nameDisplayName} field is required.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(BusinessName))
|
||||
{
|
||||
var businessNameDisplayName = nameof(BusinessName).GetDisplayAttribute<CreateProviderModel>()?.GetName();
|
||||
var businessNameDisplayName = nameof(BusinessName).GetDisplayAttribute<CreateProviderModel>()?.GetName() ?? nameof(BusinessName);
|
||||
yield return new ValidationResult($"The {businessNameDisplayName} field is required.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(BillingEmail))
|
||||
{
|
||||
var billingEmailDisplayName = nameof(BillingEmail).GetDisplayAttribute<CreateProviderModel>()?.GetName();
|
||||
var billingEmailDisplayName = nameof(BillingEmail).GetDisplayAttribute<CreateProviderModel>()?.GetName() ?? nameof(BillingEmail);
|
||||
yield return new ValidationResult($"The {billingEmailDisplayName} field is required.");
|
||||
}
|
||||
break;
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
<form method="post">
|
||||
<div asp-validation-summary="All" class="alert alert-danger"></div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Type" class="h2"></label>
|
||||
@foreach(ProviderType providerType in Enum.GetValues(typeof(ProviderType)))
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
<div id="@($"info-{(int)ProviderType.Msp}")" class="form-group @(Model.Type != ProviderType.Msp ? "d-none" : string.Empty)">
|
||||
<h2>MSP Info</h2>
|
||||
<div class="form-group">
|
||||
@ -39,9 +39,13 @@
|
||||
<input type="text" class="form-control" asp-for="OwnerEmail">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="@($"info-{(int)ProviderType.Reseller}")" class="form-group @(Model.Type != ProviderType.Reseller ? "d-none" : string.Empty)">
|
||||
<h2>Reseller Info</h2>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name"></label>
|
||||
<input type="text" class="form-control" asp-for="Name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="BusinessName"></label>
|
||||
<input type="text" class="form-control" asp-for="BusinessName">
|
||||
@ -51,6 +55,6 @@
|
||||
<input type="text" class="form-control" asp-for="BillingEmail">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary mb-2">Create Provider</button>
|
||||
</form>
|
||||
|
@ -0,0 +1,5 @@
|
||||
-- Reseller Providers were being created with a NULL value in the [Name] column.
|
||||
-- This script will populate them with the value from [BusinessName] which was already required.
|
||||
UPDATE [dbo].[Provider]
|
||||
SET [Name] = [BusinessName]
|
||||
WHERE [Name] IS NULL
|
Loading…
x
Reference in New Issue
Block a user