wabbajack/Wabbajack.Server/DataModels/AuthorKeys.cs
2021-11-27 11:31:35 -07:00

28 lines
698 B
C#

using System.Threading.Tasks;
using Wabbajack.BuildServer;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
namespace Wabbajack.Server.DataModels;
public class AuthorKeys
{
private readonly AppSettings _settings;
private AbsolutePath AuthorKeysPath => _settings.AuthorAPIKeyFile.ToAbsolutePath();
public AuthorKeys(AppSettings settings)
{
_settings = settings;
}
public async Task<string?> AuthorForKey(string key)
{
await foreach (var line in AuthorKeysPath.ReadAllLinesAsync())
{
var parts = line.Split("\t");
if (parts[0].Trim() == key)
return parts[1].Trim();
}
return null;
}
}