public ActionResult SetPassword(SetPasswordViewModel model)
        {
            if (model == null)
            {
                return null;
            }

            if (!this.ControllerContext.HttpContext.Request.IsAuthenticated && model.PasswordResetKey == Guid.Empty)
            {
                return null;
            }

            if (ModelState.IsValid)
            {
                SaveResult<UserViewModel> result;
                var email = StrixPlatform.Environment.CurrentUserEmail;

                if (!string.IsNullOrWhiteSpace(email) && model.OldPassword != null && model.OldPassword.ToString() != model.PasswordResetKey.ToString())
                {
                    result = this._accountService.ChangePassword(email, model.OldPassword, model.NewPassword);
                }
                else
                {
                    var user = this._accountService.GetUserByResetKey(model.PasswordResetKey);
                    result = this._accountService.ChangePassword(user.Email, null, model.NewPassword, model.PasswordResetKey);
                }

                if (result.Success && result.Message == null)
                {
                    this.TempData["ReturnUrl"] = model.ReturnUrl;
                    this.TempData["PasswordSetMode"] = model.PasswordResetKey == Guid.Empty ? "Change" : "Register";
                    return this.RedirectToAction("SetPasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                }
            }

            ViewBag.MinRequiredNonalphanumericCharacters = StrixMembership.Configuration.Password.MinRequiredNonAlphanumericCharacters;
            ViewBag.PasswordLength = StrixMembership.Configuration.Password.MinRequiredPasswordLength;
            return this.View(model);
        }
        public ActionResult SetPassword(Guid? key)
        {
            SetPasswordViewModel model = new SetPasswordViewModel();

            if (key.HasValue)
            {
                var user = this._accountService.GetUserByResetKey(key.Value);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, Resources.Interface.InvalidPasswordSetKey);
                }

                model.PasswordResetKey = key.Value;
            }

            ViewBag.MinRequiredNonalphanumericCharacters = StrixMembership.Configuration.Password.MinRequiredNonAlphanumericCharacters;
            ViewBag.PasswordLength = StrixMembership.Configuration.Password.MinRequiredPasswordLength;
            model.ReturnUrl = this.Request != null && this.Request.UrlReferrer != null ? this.Request.UrlReferrer.ToString() : null;
            return this.View(model);
        }