1
0
mirror of https://github.com/bitwarden/server synced 2025-12-22 03:03:33 +00:00

Add support for setting email verified and premium in seed

This commit is contained in:
Hinton
2025-10-10 12:11:30 -07:00
parent 99fb70ae6b
commit 45ba8f83df
2 changed files with 5 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ public class UserSeeder(RustSdkService sdkService, IPasswordHasher<Bit.Core.Enti
return $"{mangleId}+{email}"; return $"{mangleId}+{email}";
} }
public User CreateUser(string email) public User CreateUser(string email, bool emailVerified = false, bool premium = false)
{ {
email = MangleEmail(email); email = MangleEmail(email);
var keys = sdkService.GenerateUserKeys(email, "asdfasdfasdf"); var keys = sdkService.GenerateUserKeys(email, "asdfasdfasdf");
@@ -34,11 +34,13 @@ public class UserSeeder(RustSdkService sdkService, IPasswordHasher<Bit.Core.Enti
{ {
Id = CoreHelpers.GenerateComb(), Id = CoreHelpers.GenerateComb(),
Email = email, Email = email,
EmailVerified = emailVerified,
MasterPassword = null, MasterPassword = null,
SecurityStamp = "4830e359-e150-4eae-be2a-996c81c5e609", SecurityStamp = "4830e359-e150-4eae-be2a-996c81c5e609",
Key = keys.EncryptedUserKey, Key = keys.EncryptedUserKey,
PublicKey = keys.PublicKey, PublicKey = keys.PublicKey,
PrivateKey = keys.PrivateKey, PrivateKey = keys.PrivateKey,
Premium = premium,
ApiKey = "7gp59kKHt9kMlks0BuNC4IjNXYkljR", ApiKey = "7gp59kKHt9kMlks0BuNC4IjNXYkljR",
Kdf = KdfType.PBKDF2_SHA256, Kdf = KdfType.PBKDF2_SHA256,

View File

@@ -6,9 +6,9 @@ namespace Bit.Seeder.Recipes;
public class SingleUserRecipe(DatabaseContext db, UserSeeder userSeeder) public class SingleUserRecipe(DatabaseContext db, UserSeeder userSeeder)
{ {
public RecipeResult Seed(string email) public RecipeResult Seed(string email, bool emailVerified = false, bool premium = false)
{ {
var user = userSeeder.CreateUser(email); var user = userSeeder.CreateUser(email, emailVerified, premium);
db.Add(user); db.Add(user);
db.SaveChanges(); db.SaveChanges();