Add project files.

This commit is contained in:
EugeneTes
2026-01-13 09:06:47 +01:00
parent dd935fe1fa
commit 7390693f50
187 changed files with 83457 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System.Text.Json;
namespace ConfigurationPannel.Services;
public class UserService
{
private readonly string _usersFilePath;
public UserService(IWebHostEnvironment env)
{
_usersFilePath = Path.Combine(env.ContentRootPath, "users.json");
}
public async Task<bool> ValidateCredentialsAsync(string username, string password)
{
if (!File.Exists(_usersFilePath))
return false;
var json = await File.ReadAllTextAsync(_usersFilePath);
var userStore = JsonSerializer.Deserialize<UserStore>(json, new JsonSerializerOptions(){PropertyNameCaseInsensitive = true});
var user = userStore?.Users.FirstOrDefault(u => u.Username == username);
if (user == null)
return false;
return user.Password==password;
}
}
public class UserStore
{
public List<User> Users { get; set; } = new();
}
public class User
{
public string Username { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}