Use TryGetValue() in TokenExtensions (#23708)
This commit is contained in:
parent
6b2ece7e21
commit
54bd692c78
|
|
@ -13,8 +13,8 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class AuthenticationTokenExtensions
|
public static class AuthenticationTokenExtensions
|
||||||
{
|
{
|
||||||
private static string TokenNamesKey = ".TokenNames";
|
private const string TokenNamesKey = ".TokenNames";
|
||||||
private static string TokenKeyPrefix = ".Token.";
|
private const string TokenKeyPrefix = ".Token.";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores a set of authentication tokens, after removing any old tokens.
|
/// Stores a set of authentication tokens, after removing any old tokens.
|
||||||
|
|
@ -76,9 +76,8 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
}
|
}
|
||||||
|
|
||||||
var tokenKey = TokenKeyPrefix + tokenName;
|
var tokenKey = TokenKeyPrefix + tokenName;
|
||||||
return properties.Items.ContainsKey(tokenKey)
|
|
||||||
? properties.Items[tokenKey]
|
return properties.Items.TryGetValue(tokenKey, out var value) ? value : null;
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
|
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue