mirror of
https://github.com/bitwarden/server
synced 2026-02-18 10:23:27 +00:00
30 lines
1019 B
C#
30 lines
1019 B
C#
using Bit.Core.Enums;
|
|
using Bit.RustSDK;
|
|
using Bit.Seeder.Factories;
|
|
using Bit.Seeder.Pipeline;
|
|
|
|
namespace Bit.Seeder.Steps;
|
|
|
|
/// <summary>
|
|
/// Creates the owner user and links them to the current organization.
|
|
/// </summary>
|
|
internal sealed class CreateOwnerStep : IStep
|
|
{
|
|
public void Execute(SeederContext context)
|
|
{
|
|
var org = context.RequireOrganization();
|
|
var owner = UserSeeder.Create($"owner@{context.RequireDomain()}", context.GetPasswordHasher(), context.GetMangler());
|
|
|
|
var ownerOrgKey = RustSdkService.GenerateUserOrganizationKey(owner.PublicKey!, context.RequireOrgKey());
|
|
var ownerOrgUser = org.CreateOrganizationUserWithKey(
|
|
owner, OrganizationUserType.Owner, OrganizationUserStatusType.Confirmed, ownerOrgKey);
|
|
|
|
context.Owner = owner;
|
|
context.OwnerOrgUser = ownerOrgUser;
|
|
|
|
context.Users.Add(owner);
|
|
context.OrganizationUsers.Add(ownerOrgUser);
|
|
context.Registry.HardenedOrgUserIds.Add(ownerOrgUser.Id);
|
|
}
|
|
}
|