in src/Amazon.AspNetCore.Identity.Cognito/CognitoUserStore/CognitoUserStore.cs [502:526]
private async Task<string> GetAttributeValueAsync(TUser user, string attributeName, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (user.Attributes == null)
{
throw new ArgumentException("user.Attributes must be initialized.");
}
var clientConfig = await _pool.GetUserPoolClientConfiguration().ConfigureAwait(false);
if (!clientConfig.ReadAttributes?.Contains(attributeName) ?? true)
{
throw new NotAuthorizedException(string.Format("Reading attribute {0} is not allowed by the user pool client configuration.", attributeName));
}
// There is an edge case where an attribute might be there in the pool configuration, but not on the user profile
if (user.Attributes.ContainsKey(attributeName))
{
return user.Attributes[attributeName];
}
else
{
return null;
}
}