Add UpdateTokenValue API

This commit is contained in:
Hao Kung 2016-07-29 13:26:25 -07:00
parent c16fc06cb9
commit 2a6ab2be8c
1 changed files with 20 additions and 0 deletions

View File

@ -63,6 +63,26 @@ namespace Microsoft.AspNetCore.Authentication
: null;
}
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
{
if (properties == null)
{
throw new ArgumentNullException(nameof(properties));
}
if (tokenName == null)
{
throw new ArgumentNullException(nameof(tokenName));
}
var tokenKey = TokenKeyPrefix + tokenName;
if (!properties.Items.ContainsKey(tokenKey))
{
return false;
}
properties.Items[tokenKey] = tokenValue;
return true;
}
public static IEnumerable<AuthenticationToken> GetTokens(this AuthenticationProperties properties)
{
if (properties == null)