public static CommandBuilder <InStoreCommand <T>, T> ChangePassword <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     IVersioned <T> resource,
     string currentPassword,
     string newPassword)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <T>, T>(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand = new ChangeCustomerPasswordCommand(resource.Id, resource.Version, currentPassword, newPassword) as ChangePasswordCommand <T>;
         var newInStoreCommand = new InStoreCommand <T>(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
        public async Task ChangeCustomerPassword()
        {
            var oldPassword = TestingUtility.RandomString();

            await WithUpdateableCustomer(
                client, customerDraft => DefaultCustomerDraftWithPassword(customerDraft, oldPassword), async customer =>
            {
                var newPassword     = TestingUtility.RandomString();
                var command         = new ChangeCustomerPasswordCommand(customer, oldPassword, newPassword);
                var updatedCustomer = await client
                                      .ExecuteAsync(command);
                //login with the new password to make Sure that password changed
                var loginResult =
                    await client.ExecuteAsync(new LoginCustomerCommand(updatedCustomer.Email, newPassword));
                Assert.NotNull(loginResult);
                return(updatedCustomer);
            });
        }
Ejemplo n.º 3
0
        public void PostChangePassword(int id, [FromBody] string password)
        {
            var customerId = string.Format("customers/{0}", id);
            var command    = new ChangeCustomerPasswordCommand(customerId, password);

            try
            {
                ExecuteCommand(command);

                if (!command.Success)
                {
                    // cry
                }
            }
            catch
            {
                // infrastructure exceptions
            }
        }