1 using Microsoft.EntityFrameworkCore;
4 using System.Threading;
5 using System.Threading.Tasks;
38 CreatedAt = DateTimeOffset.Now,
40 Name = Api.Models.User.AdminName,
41 CanonicalName = Api.Models.User.AdminName.ToUpperInvariant(),
45 databaseContext.
Users.Add(admin);
52 await databaseContext.
Save(cancellationToken).ConfigureAwait(
false);
58 var admin = await databaseContext.
Users.Where(x => x.CanonicalName == Api.Models.User.AdminName.ToUpperInvariant()).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(
false);
67 await databaseContext.
Save(cancellationToken).ConfigureAwait(
false);
readonly ICryptographySuite cryptographySuite
The ICryptographySuite for the DatabaseContext<TParentContext>
For initially seeding a database
async Task SeedDatabase(IDatabaseContext databaseContext, CancellationToken cancellationToken)
Initially seed a given databaseContext
AdministrationRights
Rights for Models.Administration
Contains various cryptographic functions
async Task ResetAdminPassword(IDatabaseContext databaseContext, CancellationToken cancellationToken)
Changes the admin password in IDatabaseContext back to it's default and enables the account
InstanceManagerRights
Rights for managing Models.Instances
DatabaseSeeder(ICryptographySuite cryptographySuite)
Construct a DatabaseSeeder
void SetUserPassword(User user, string newPassword, bool newUser)
Sets a User.PasswordHash for a given user
DbSet< User > Users
The Users in the IDatabaseContext
Task Save(CancellationToken cancellationToken)
Saves changes made to the IDatabaseContext
void SeedAdminUser(IDatabaseContext databaseContext)
Add a default admin User to a given databaseContext