Skip to content
代码片段 群组 项目
未验证 提交 54bd692c 编辑于 作者: Martin Costello's avatar Martin Costello 提交者: GitHub
浏览文件

Use TryGetValue() in TokenExtensions (#23708)

上级 6b2ece7e
No related branches found
No related tags found
无相关合并请求
......@@ -13,8 +13,8 @@ namespace Microsoft.AspNetCore.Authentication
/// </summary>
public static class AuthenticationTokenExtensions
{
private static string TokenNamesKey = ".TokenNames";
private static string TokenKeyPrefix = ".Token.";
private const string TokenNamesKey = ".TokenNames";
private const string TokenKeyPrefix = ".Token.";
/// <summary>
/// Stores a set of authentication tokens, after removing any old tokens.
......@@ -76,9 +76,8 @@ namespace Microsoft.AspNetCore.Authentication
}
var tokenKey = TokenKeyPrefix + tokenName;
return properties.Items.ContainsKey(tokenKey)
? properties.Items[tokenKey]
: null;
return properties.Items.TryGetValue(tokenKey, out var value) ? value : null;
}
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册