1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

default collection on org create

This commit is contained in:
Kyle Spearrin
2017-08-30 21:25:46 -04:00
parent 20779014b0
commit e43c3baf6e
6 changed files with 28 additions and 14 deletions

View File

@ -18,7 +18,8 @@ namespace Bit.Core.Services
Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
Task VerifyBankAsync(Guid organizationId, int amount1, int amount2);
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationSignup organizationSignup);
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationLicense license, User owner, string ownerKey);
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationLicense license, User owner,
string ownerKey, string collectionName);
Task UpdateLicenseAsync(Guid organizationId, OrganizationLicense license);
Task DeleteAsync(Organization organization);
Task DisableAsync(Guid organizationId, DateTime? expirationDate);

View File

@ -537,11 +537,11 @@ namespace Bit.Core.Services
RevisionDate = DateTime.UtcNow
};
return await SignUpAsync(organization, signup.Owner.Id, signup.OwnerKey, true);
return await SignUpAsync(organization, signup.Owner.Id, signup.OwnerKey, signup.CollectionName, true);
}
public async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(
OrganizationLicense license, User owner, string ownerKey)
OrganizationLicense license, User owner, string ownerKey, string collectionName)
{
if(license == null || !_licensingService.VerifyLicense(license))
{
@ -584,7 +584,7 @@ namespace Bit.Core.Services
RevisionDate = DateTime.UtcNow
};
var result = await SignUpAsync(organization, owner.Id, ownerKey, false);
var result = await SignUpAsync(organization, owner.Id, ownerKey, collectionName, false);
var dir = $"{_globalSettings.LicenseDirectory}/organization";
Directory.CreateDirectory(dir);
@ -594,7 +594,7 @@ namespace Bit.Core.Services
}
private async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(Organization organization,
Guid ownerId, string ownerKey, bool withPayment)
Guid ownerId, string ownerKey, string collectionName, bool withPayment)
{
try
{
@ -614,14 +614,17 @@ namespace Bit.Core.Services
await _organizationUserRepository.CreateAsync(orgUser);
var defaultCollection = new Collection
if(!string.IsNullOrWhiteSpace(collectionName))
{
Name = "Default Collection",
OrganizationId = organization.Id,
CreationDate = organization.CreationDate,
RevisionDate = organization.CreationDate
};
await _collectionRepository.CreateAsync(defaultCollection);
var defaultCollection = new Collection
{
Name = collectionName,
OrganizationId = organization.Id,
CreationDate = organization.CreationDate,
RevisionDate = organization.CreationDate
};
await _collectionRepository.CreateAsync(defaultCollection);
}
// push
var deviceIds = await GetUserDeviceIdsAsync(orgUser.UserId.Value);