public IHttpActionResult ResetPasswordToken(ResetPasswordRequest request)
        {
            var response = new SignInResponse();

            try
            {
                var isValidRequest = false;

                var memberId = request.GetMemberId();
                var member = MembershipAdapter.GetMember(request.Token);

                if (request.IsValidModel())
                {
                    if (!request.PasswordsMatch())
                    {
                        request.AddError("Password", "Passwords do not match");
                    }
                    else
                    {
                        if (member.Exists())
                        {
                            if (memberId == member.Id)
                            {
                                if (member.HasTokens())
                                {
                                    if (member.Tokens.ElementAt(0).IsValid(TokenTypes.PasswordReset))
                                    {
                                        isValidRequest = true;
                                    }
                                }
                            }
                        }
                    }
                }

                if (isValidRequest)
                {
                    var memberPassword = new MemberPassword();
                    memberPassword.MemberId = member.Id;
                    memberPassword.InitializePassword(request.Password);

                    MembershipAdapter.UpdatePassword(memberPassword);

                    var memberToken = new MemberToken
                    {
                        Token = member.Tokens.ElementAt(0).Token,
                        MemberId = member.Id,
                        TokenType = member.Tokens.ElementAt(0).TokenType,
                        ExpirationDate = member.Tokens.ElementAt(0).ExpirationDate,
                        ConfirmedDate = DateTime.Now.ToUniversalTime(),
                        RequestDate = member.Tokens.ElementAt(0).RequestDate
                    };

                    MembershipAdapter.UpdateToken(memberToken);

                    response.MemberId = member.Id.ToString();
                    response.Alias = member.Profile.Alias;
                    response.IsActive = member.IsActive;
                    response.IsAdmin = member.IsAdmin;

                    var email = new ResetPasswordEmail
                    {
                        DomainName = ConfigHelper.DomainName,
                        DomainBaseUrl = ConfigHelper.DomainBaseUrl,
                        Alias = member.Profile.Alias
                    };

                    var emailBuilder = new EmailBuilder(EmailReference.HTML.Templates.Main, EmailReference.HTML.Contents.ResetPassword);
                    var emailBody = emailBuilder.BuildBody<ResetPasswordEmail>(email);
                    var emailResult = EmailHelper.SendEmail(ConfigHelper.NoReplayEmailAddress,
                                                            ConfigHelper.DomainName,
                                                            member.Email,
                                                            member.Profile.Alias,
                                                            email.Subject,
                                                            emailBody,
                                                            true);

                    if (emailResult)
                    {
                        response.IsSuccessful = true;
                        response.StatusMessage = "Reset password succeeded";
                    }
                }
                else
                {
                    response.IsSuccessful = false;
                    response.StatusMessage = "Reset password was unsuccessful";
                    response.Errors.AddRange(request.GetErrors());
                }
            }
            catch (Exception ex)
            {
                request.Password = string.Empty;
                request.PasswordConfirm = string.Empty;

                this.Log<ResetPasswordRequest>(LogCategories.Error, request, ex.Message);

                response.IsSuccessful = false;
                response.StatusMessage = this.StatusMessageForExpection;
                response.Errors.Add(ex.Message);
            }

            return Ok(response);
        }
        public void ResetPasswordToken()
        {
            var memberId = this.RequestUserInput<string>("Enter member ID: ", string.Empty);
            var token = this.RequestGuid("Enter token: ");
            var password = this.RequestUserInput<string>("Enter password: "******"Re-enter password: ", string.Empty);

            var request = new ResetPasswordRequest
            {
                MemberId = memberId,
                Token = token,
                Password = password,
                PasswordConfirm = passwordConfirm
            };

            var response = proxy.ResetPasswordToken(request);

            this.OutputResponse(response);
        }