Skip to content

Commit

Permalink
fix: invalidate cache when logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
iadonkey committed Nov 30, 2023
1 parent 479980d commit 8806937
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions TwinpackShared/TwinpackServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Reflection;
using AdysTech.CredentialManager;
using System.Threading;
using System.Net.PeerToPeer;

namespace Twinpack
{
Expand All @@ -33,6 +34,13 @@ public class TwinpackServer
public LoginPostResponse UserInfo { get; set; }
public bool LoggedIn { get { return UserInfo?.User != null; } }

public TwinpackServer()
{
var credentials = CredentialManager.GetCredentials(TwinpackUrlBase);
Username = credentials?.UserName;
Password = credentials?.Password;
}

public Version ClientVersion
{
get
Expand Down Expand Up @@ -414,6 +422,7 @@ public async Task<PackageGetResponse> PutPackageAsync(PackagePatchRequest packag

public async Task<LoginPostResponse> LoginAsync(string username = null, string password = null, CancellationToken cancellationToken = default)
{
_client.Invalidate(); // clear the cache
var credentials = CredentialManager.GetCredentials(TwinpackUrlBase);

var request = new HttpRequestMessage(HttpMethod.Post, new Uri(TwinpackUrl + "/login"));
Expand Down

0 comments on commit 8806937

Please sign in to comment.