public ActionResult ResetPassword(string username, string resetPasswordCode, string newPassword)
        {
            if (String.IsNullOrEmpty(username))
            {
                ModelState.AddModelError("username", "Invalid username.", username);
            }

            if (String.IsNullOrEmpty(resetPasswordCode))
            {
                ModelState.AddModelError("resetPasswordCode", "Invalid Password Reset Code.", resetPasswordCode);
            }

            if (ModelState.IsValid)
            {
                CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.Provider.GetUser(username, false);
                if (user != null)
                {
                    if (user.CheckResetPasswordCode(resetPasswordCode))
                    {
                        newPassword = user.ResetPassword(resetPasswordCode);
                        if (!String.IsNullOrEmpty(newPassword))
                        {
                            // Clear out the reset password code so it cannot be used again
                            user.ClearResetPasswordCode();

                            // Display username
                            ViewData["username"] = username;

                            // Display new password
                            ViewData["newPassword"] = newPassword;

                            return(View("ResetPasswordSuccess"));
                        }
                        else
                        {
                            ModelState.AddModelError("resetPasswordCode", "Unable to reset password.", resetPasswordCode);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("resetPasswordCode", "Invalid/Expired Password Reset Code.", resetPasswordCode);
                    }
                }
                else
                {
                    ModelState.AddModelError("username", "Invalid username.", username);
                }
            }

            return(View("ResetPasswordError"));
        }
        /// <summary>
        /// Resets the password.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="resetPasswordCode">The reset password code.</param>
        /// <returns>The ResetPassword view when username/resetPasswordCode are valid. ResetPasswordError view when either is invalid.</returns>
        public ActionResult ResetPassword(string username, string resetPasswordCode)
        {
            if (String.IsNullOrEmpty(username))
            {
                ModelState.AddModelError("username", "Invalid username.", username);
            }

            if (String.IsNullOrEmpty(resetPasswordCode))
            {
                ModelState.AddModelError("resetPasswordCode", "Invalid Password Reset Code.", resetPasswordCode);
            }

            if (ModelState.IsValid)
            {
                CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.Provider.GetUser(username, false);
                if (user != null)
                {
                    if (user.CheckResetPasswordCode(resetPasswordCode))
                    {
                        // Display the username
                        ViewData["username"] = username;

                        return(View());
                    }
                    else
                    {
                        ModelState.AddModelError("resetPasswordCode", "Invalid/Expired Password Reset Code.", resetPasswordCode);
                    }
                }
                else
                {
                    ModelState.AddModelError("username", "Invalid username.", username);
                }
            }

            return(View("ResetPasswordError"));
        }