コード例 #1
0
    internal async Task <System.Net.HttpStatusCode> UpdateAttributes(UpdateUserAttributesRequest a)
    {
        AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials());
        UpdateUserAttributesResponse        resp     = await provider.UpdateUserAttributesAsync(a);

        return(resp.HttpStatusCode);
    }
コード例 #2
0
        public async Task <RequestResult> UpdateUserDetails(User user)
        {
            RequestResult result = new RequestResult();

            try
            {
                GetUserResponse response = new GetUserResponse();

                if (cognitoUserSession != null && cognitoUserSession.IsValid())
                {
                    List <AttributeType> attributes = new List <AttributeType>();
                    attributes.Add(new AttributeType()
                    {
                        Name = "custom:firstname", Value = user.FirstName
                    });
                    attributes.Add(new AttributeType()
                    {
                        Name = "custom:lastname", Value = user.LastName
                    });

                    UpdateUserAttributesRequest rr = new UpdateUserAttributesRequest()
                    {
                        AccessToken    = cognitoUserSession.AccessToken,
                        UserAttributes = attributes
                    };

                    await provider.UpdateUserAttributesAsync(rr);

                    result.Data    = response;
                    result.Status  = true;
                    result.Message = "User Info updated successfully.";
                }
                else
                {
                    result.Status  = false;
                    result.Message = "Invalid Sesson";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }

            return(result);
        }