30 lines
968 B
C#
30 lines
968 B
C#
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";
|
|
|
|
[JsonIgnore]
|
|
public static string FilePath => PathBuilder.Combine(FileName);
|
|
|
|
public required string Username { get; set; }
|
|
public required string Email { get; set; }
|
|
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<OAuthProvider, OAuthUser>? OAuthProviders { get; set; }
|
|
|
|
public void SaveSetting()
|
|
{
|
|
File.WriteAllText(FilePath, JsonSerializer.Serialize(this));
|
|
}
|
|
} |