mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
organization signup apis and data model changes
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Business;
|
||||
using System;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
@ -7,19 +8,18 @@ namespace Bit.Api.Models
|
||||
public class OrganizationCreateRequestModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public PlanType Plan { get; set; }
|
||||
// TODO: Billing info for paid plans.
|
||||
public PlanType PlanType { get; set; }
|
||||
public string Key { get; set; }
|
||||
|
||||
public virtual Organization ToOrganization(Guid userId)
|
||||
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
||||
{
|
||||
var organization = new Organization
|
||||
return new OrganizationSignup
|
||||
{
|
||||
UserId = userId,
|
||||
Owner = user,
|
||||
OwnerKey = Key,
|
||||
Name = Name,
|
||||
Plan = Plan
|
||||
Plan = PlanType
|
||||
};
|
||||
|
||||
return organization;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ namespace Bit.Api.Models
|
||||
JsonConvert.DeserializeObject<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) :
|
||||
new List<GlobalEquivalentDomainsType>();
|
||||
var globalDomains = new List<GlobalDomains>();
|
||||
var domainsToInclude = excluded ? Core.Utilities.EquivalentDomains.Global :
|
||||
Core.Utilities.EquivalentDomains.Global.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
|
||||
var domainsToInclude = excluded ? Core.Utilities.StaticStore.GlobalDomains :
|
||||
Core.Utilities.StaticStore.GlobalDomains.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
|
||||
foreach(var domain in domainsToInclude)
|
||||
{
|
||||
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains, excluded));
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class OrganizationResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationResponseModel(Organization organization)
|
||||
: base("organization")
|
||||
public OrganizationResponseModel(Organization organization, string obj = "organization")
|
||||
: base(obj)
|
||||
{
|
||||
if(organization == null)
|
||||
{
|
||||
@ -17,12 +16,32 @@ namespace Bit.Api.Models
|
||||
Id = organization.Id.ToString();
|
||||
Name = organization.Name;
|
||||
Plan = organization.Plan;
|
||||
PlanType = organization.PlanType;
|
||||
PlanTrial = organization.PlanTrial;
|
||||
MaxUsers = organization.MaxUsers;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public PlanType Plan { get; set; }
|
||||
public string Plan { get; set; }
|
||||
public Core.Enums.PlanType PlanType { get; set; }
|
||||
public bool PlanTrial { get; set; }
|
||||
public short MaxUsers { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationExtendedResponseModel : OrganizationResponseModel
|
||||
{
|
||||
public OrganizationExtendedResponseModel(Organization organization, OrganizationUser organizationUser)
|
||||
: base(organization, "organizationExtended")
|
||||
{
|
||||
if(organizationUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
}
|
||||
|
||||
Key = organizationUser.Key;
|
||||
}
|
||||
|
||||
public string Key { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user