Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/Commands/Base/PnPConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ internal static PnPConnection CreateWithDeviceLogin(string clientId, string url,
{
EnableCaching(url, clientId);
}
if (CacheEnabled(url, clientId))
if (persistLogin && CacheEnabled(url, clientId))
{
WriteCacheEnabledMessage(host);
}
Expand All @@ -287,7 +287,10 @@ internal static PnPConnection CreateWithDeviceLogin(string clientId, string url,
return Task.FromResult(0);
}, azureEnvironment, tokenCacheCallback: async (tokenCache) =>
{
await MSALCacheHelper(tokenCache, url, clientId);
if (persistLogin)
{
await MSALCacheHelper(tokenCache, url, clientId);
}
});
}
using (authManager)
Expand Down Expand Up @@ -458,7 +461,7 @@ internal static PnPConnection CreateWithCredentials(Cmdlet cmdlet, Uri url, PSCr
{
EnableCaching(url.ToString(), clientId);
}
if (CacheEnabled(url.ToString(), clientId))
if (persistLogin && CacheEnabled(url.ToString(), clientId))
{
WriteCacheEnabledMessage(host);
}
Expand Down Expand Up @@ -492,7 +495,10 @@ internal static PnPConnection CreateWithCredentials(Cmdlet cmdlet, Uri url, PSCr
{
authManager = PnP.Framework.AuthenticationManager.CreateWithCredentials(clientId, credentials.UserName, credentials.Password, redirectUrl, azureEnvironment, tokenCacheCallback: async (tokenCache) =>
{
await MSALCacheHelper(tokenCache, url.ToString(), clientId);
if (persistLogin)
{
await MSALCacheHelper(tokenCache, url.ToString(), clientId);
}
});
}
using (authManager)
Expand Down Expand Up @@ -603,7 +609,7 @@ internal static PnPConnection CreateWithInteractiveLogin(Uri uri, string clientI
{
EnableCaching(uri.ToString(), clientId);
}
if (CacheEnabled(uri.ToString(), clientId))
if (persistLogin && CacheEnabled(uri.ToString(), clientId))
{
WriteCacheEnabledMessage(host);
}
Expand All @@ -628,7 +634,10 @@ internal static PnPConnection CreateWithInteractiveLogin(Uri uri, string clientI
htmlMessageFailure,
azureEnvironment: azureEnvironment, tokenCacheCallback: async (tokenCache) =>
{
await MSALCacheHelper(tokenCache, uri.ToString(), clientId);
if (persistLogin)
{
await MSALCacheHelper(tokenCache, uri.ToString(), clientId);
}
}, useWAM: enableLoginWithWAM);
}
using (authManager)
Expand Down
Loading