Skip to content

Commit

Permalink
Merge pull request #1585 from testfirstcoder/refactoring-authenticati…
Browse files Browse the repository at this point in the history
…on-properties-extensions

Refactoring AuthenticationPropertiesExtensions
  • Loading branch information
josephdecock authored Dec 5, 2024
2 parents 951ab04 + 6521617 commit fd42a2d
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Duende Software. All rights reserved.
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.


Expand Down Expand Up @@ -26,12 +26,7 @@ public static class AuthenticationPropertiesExtensions
/// <returns></returns>
public static string GetSessionId(this AuthenticationProperties properties)
{
if (properties?.Items.ContainsKey(SessionIdKey) == true)
{
return properties.Items[SessionIdKey];
}

return null;
return properties?.Items.TryGetValue(SessionIdKey, out var value) == true ? value : null;
}

/// <summary>
Expand All @@ -52,13 +47,12 @@ public static void SetSessionId(this AuthenticationProperties properties, string
/// <returns></returns>
public static IEnumerable<string> GetClientList(this AuthenticationProperties properties)
{
if (properties?.Items.ContainsKey(ClientListKey) == true)
if (properties?.Items.TryGetValue(ClientListKey, out var value) == true)
{
var value = properties.Items[ClientListKey];
return DecodeList(value);
}

return Enumerable.Empty<string>();
return [];
}

/// <summary>
Expand Down Expand Up @@ -100,10 +94,7 @@ public static void AddClientId(this AuthenticationProperties properties, string
var clients = properties.GetClientList();
if (!clients.Contains(clientId))
{
var update = clients.ToList();
update.Add(clientId);

properties.SetClientList(update);
properties.SetClientList(clients.Append(clientId));
}
}

Expand Down

0 comments on commit fd42a2d

Please sign in to comment.