public ActionResult Manage(ManageModel model)
        {
            var userName = Authenticator.Current;

            if (Authenticator.IsLocalAccount(userName))
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        Authenticator.ChangePassword(userName, model.OldPassword, model.NewPassword);

                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    catch (Exception)
                    {
                        ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                    }
                }
            }
            else
            {
                // User does not have a local password.
                // Remove any validation errors caused by a missing OldPassword field.
                ModelState state = ModelState["OldPassword"];

                if (state != null)
                    state.Errors.Clear();

                if (ModelState.IsValid)
                {
                    Authenticator.SetPassword(userName, model.NewPassword);

                    return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        //
        // GET: /Account/Manage

        public ActionResult Manage(ManageMessageId? message)
        {
            var userName = Authenticator.Current;
            var model    = new ManageModel
            {
                UserName         = userName,
                HasLocalPassword = Authenticator.IsLocalAccount(userName)
            };

            switch (message)
            {
                case ManageMessageId.ChangePasswordSuccess:
                    model.StatusMessage = "Your password has been changed.";

                    break;

                case ManageMessageId.SetPasswordSuccess:
                    model.StatusMessage = "Your password has been set.";

                    break;

                case ManageMessageId.RemoveLoginSuccess:
                    model.StatusMessage = "The external login was removed.";

                    break;
            }

            return View(model);
        }