using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Security.Common.Domain; using System.Collections.Generic; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; namespace Mirea.Api.Endpoint.Configuration.Model; public class Admin : ISaveSettings { [JsonIgnore] private const string FileName = "admin.json"; private string _username = string.Empty; private string _email = string.Empty; [JsonIgnore] public static string FilePath => PathBuilder.Combine(FileName); public required string Username { get => _username; set => _username = value.Trim(); } public required string Email { get => _email; set => _email = value.Trim(); } public required string PasswordHash { get; set; } public required string Salt { get; set; } public TwoFactorAuthenticator TwoFactorAuthenticator { get; set; } = TwoFactorAuthenticator.None; public string? Secret { get; set; } public Dictionary? OAuthProviders { get; set; } public void SaveSetting() { File.WriteAllText(FilePath, JsonSerializer.Serialize(this)); } }