40 lines
1.2 KiB
C#
Raw Normal View History

2024-10-07 02:25:36 +03:00
using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Security.Common.Domain;
2024-11-04 02:39:10 +03:00
using System.Collections.Generic;
2024-07-04 23:52:25 +03:00
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
2024-10-07 02:13:35 +03:00
namespace Mirea.Api.Endpoint.Configuration.Model;
2024-07-04 23:52:25 +03:00
public class Admin : ISaveSettings
{
[JsonIgnore] private const string FileName = "admin.json";
2024-12-25 05:44:37 +03:00
private string _username = string.Empty;
private string _email = string.Empty;
2024-07-04 23:52:25 +03:00
[JsonIgnore]
public static string FilePath => PathBuilder.Combine(FileName);
2024-12-25 05:44:37 +03:00
public required string Username
{
get => _username;
set => _username = value.Trim();
}
public required string Email
{
get => _email;
set => _email = value.Trim();
}
2024-07-04 23:52:25 +03:00
public required string PasswordHash { get; set; }
public required string Salt { get; set; }
2024-11-02 00:50:10 +03:00
public TwoFactorAuthenticator TwoFactorAuthenticator { get; set; } = TwoFactorAuthenticator.None;
public string? Secret { get; set; }
2024-07-04 23:52:25 +03:00
2024-11-04 02:39:10 +03:00
public Dictionary<OAuthProvider, OAuthUser>? OAuthProviders { get; set; }
2024-07-04 23:52:25 +03:00
public void SaveSetting()
{
File.WriteAllText(FilePath, JsonSerializer.Serialize(this));
}
}