Fixes #1098. Allows derived types of UserClaimsPrincipalFactory to return their own ClaimsPrincipals.

This commit is contained in:
bchavez 2017-02-09 13:20:02 -08:00 committed by Hao Kung
parent 34e7a8df27
commit 8682cc74c8
1 changed files with 11 additions and 1 deletions

View File

@ -113,7 +113,17 @@ namespace Microsoft.AspNetCore.Identity
{
id.AddClaims(await UserManager.GetClaimsAsync(user));
}
return new ClaimsPrincipal(id);
return await CreatePrincipalAsync(id);
}
/// <summary>
/// Creates a <see cref="ClaimsPrincipal"/> from a <see cref="ClaimsIdentity"/>.
/// </summary>
/// <param name="id">The <see cref="ClaimsIdentity"/> with claims.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous creation operation, containing the <see cref="ClaimsPrincipal"/> with the <see cref="ClaimsIdentity"/>.</returns>
protected virtual Task<ClaimsPrincipal> CreatePrincipalAsync(ClaimsIdentity id)
{
return Task.FromResult(new ClaimsPrincipal(id));
}
}
}