Sign Out Should Delete Stored Credential

This commit is contained in:
Alan Moon 2025-11-12 13:58:30 -08:00
parent 4361a69506
commit f1648a12c2
2 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,14 @@ namespace QtCNETAPI.Services
CredentialManager.WriteCredential(applicationName, username, accessToken, $"Access Token For User {username} On QtC.NET", CredentialPersistence.LocalMachine);
}
public void DeleteAccessToken()
{
string applicationName = "QtC.NET";
if (System.Diagnostics.Debugger.IsAttached) applicationName = "QtC.NET.Development";
CredentialManager.DeleteCredential(applicationName);
}
public string? GetAccessToken()
{
string applicationName = "QtC.NET";

View File

@ -22,6 +22,7 @@ namespace qtc_net_client_2
private ServerConfig _serverConfig;
private AudioService AudioService = new();
private ImageFactory _imgFactory = new();
private CredentialService _credService = new();
private LoggingService LoggingService;
public List<Room> RoomList = [];
@ -162,7 +163,7 @@ namespace qtc_net_client_2
{
if (MessageBox.Show("Are You Sure You Want To Sign Out?\nThis Deletes Your session.token, Requiring You To Sign In Again", "are you sure...?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
File.Delete("./session.token");
_credService.DeleteAccessToken();
Environment.Exit(0);
}
}