healthchecks

This commit is contained in:
2025-08-25 18:52:59 +02:00
parent 5777e351bf
commit 0560a40876
33 changed files with 317 additions and 127 deletions

View File

@@ -4,12 +4,14 @@ using back.persistance.data;
using back.persistance.data.repositories.Abstracts;
using back.services.engine.Crypto;
using back.services.engine.PasswordGenerator;
using System.Text.Json;
using Transactional.Abstractions.Interfaces;
namespace back.services.engine.SystemUser;
public class SystemUserGenerator(
ITransactionalService<DataContext> transactional,
JsonSerializerOptions jsonSerializerOptions,
IUserRepository userRepository,
IPersonRepository personRepository,
ICryptoService cryptoService,
@@ -21,9 +23,9 @@ public class SystemUserGenerator(
var systemKey = new SystemKey() {
Password = passwordGenerator.Generate(16),
};
var systemKeyJson = System.Text.Json.JsonSerializer.Serialize(systemKey);
var systemKeyJson = JsonSerializer.Serialize(systemKey, options: jsonSerializerOptions);
using Stream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(systemKeyJson));
using Stream stream = new MemoryStream(new System.Text.UTF8Encoding(true).GetBytes(systemKeyJson));
await blobStorageService.Delete("systemkey.lock");
@@ -38,10 +40,16 @@ public class SystemUserGenerator(
if (!await userRepository.Exists(User.SystemUser.Id!))
{
await transactional.DoTransaction(async () => {
await transactional.DoTransaction(async () =>
{
await personRepository.Insert(Person.SystemPerson);
await userRepository.Insert(User.SystemUser);
});
}
else
{
await userRepository.Update(User.SystemUser);
await userRepository.SaveChanges();
}
}
}