using Meziantou.Framework.Win32;

namespace qtc_net_client_2.Services
{
    public class CredentialService()
    {
        public void SaveAccessToken(string username, string accessToken) => CredentialManager.WriteCredential("QtC.NET", username, accessToken, $"Access Token For User {username} On QtC.NET", CredentialPersistence.LocalMachine);

        public string? GetAccessToken()
        {
            var credential = CredentialManager.ReadCredential("QtC.NET");
            if (credential == null) return null;

            return credential.Password;
        }
    }
}
