in src/Amazon.AspNetCore.Identity.Cognito/CognitoUserStore/CognitoUserStore.IUserRoleStore.cs [185:214]
public virtual async Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
try
{
// Only update user writable attributes.
var clientConfig = await _pool.GetUserPoolClientConfiguration().ConfigureAwait(false);
var newValues = clientConfig.WriteAttributes?
.Where(key => user.Attributes.ContainsKey(key))
.ToDictionary(key => key, key => user.Attributes[key]) ?? new Dictionary<string, string>();
await _cognitoClient.AdminUpdateUserAttributesAsync(new AdminUpdateUserAttributesRequest
{
UserAttributes = CreateAttributeList(newValues),
Username = user.Username,
UserPoolId = _pool.PoolID
}, cancellationToken).ConfigureAwait(false);
return IdentityResult.Success;
}
catch (AmazonCognitoIdentityProviderException e)
{
return IdentityResult.Failed(_errorDescribers.CognitoServiceError("Failed to update the Cognito User", e));
}
}