当前位置: 首页>>代码示例>>C#>>正文


C# ChangePasswordModel类代码示例

本文整理汇总了C#中ChangePasswordModel的典型用法代码示例。如果您正苦于以下问题:C# ChangePasswordModel类的具体用法?C# ChangePasswordModel怎么用?C# ChangePasswordModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChangePasswordModel类属于命名空间,在下文中一共展示了ChangePasswordModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChangePassword

 public ActionResult ChangePassword(ChangePasswordModel model)
 {
     if (!ModelState.IsValid)
         return View(model);
     servicoAutorizacao.AlterarSenha(User.Identity.Name, model.OldPassword, model.NewPassword);
     return RedirectToAction("ChangePasswordSuccess");
 }
开发者ID:diegocaxito,项目名称:TeAjudo,代码行数:7,代码来源:AccountController.cs

示例2: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword iniciará una excepción en lugar de
                // devolver false en determinados escenarios de error.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(EncodePassword(model.OldPassword), EncodePassword(model.NewPassword));
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "La contraseña actual es incorrecta o la nueva contraseña no es válida.");
                }
            }

            // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
            return View(model);
        }
开发者ID:zheref,项目名称:LacteosTolima,代码行数:31,代码来源:AccountController.cs

示例3: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                var status = _userService.ChangePassword(UserProfile.Current, model.OldPassword, model.NewPassword);

                switch (status)
                {
                    case ChangePasswordStatus.Success:

                        TempData.AddSuccessMessage(status.GetDescription());
                        return RedirectToAction("Index", "Home");

                    case ChangePasswordStatus.InvalidPassword:
                        ModelState.AddModelError(string.Empty, status.GetDescription());
                        break;
                    case ChangePasswordStatus.Failure:
                        ModelState.AddModelError(string.Empty, status.GetDescription());
                        break;
                }
            }

            ViewBag.PasswordLength = _membershipSetings.MinimumPasswordLength;
            return View(model);
        }
开发者ID:havearun,项目名称:ScaffR-Generated,代码行数:25,代码来源:AccountController.ChangePassword.cs

示例4: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid) {

                // ChangePassword는 특정 실패 시나리오에서 false를 반환하지 않고
                // 예외를 throw합니다.
                bool changePasswordSucceeded;
                try {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                }
                catch (Exception) {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded) {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else {
                    ModelState.AddModelError("", "현재 암호가 정확하지 않거나 새 암호가 잘못되었습니다.");
                }
            }

            // 이 경우 오류가 발생한 것이므로 폼을 다시 표시하십시오.
            return View(model);
        }
开发者ID:powerumc,项目名称:VS2012_UPDATE2_KOR_PATCH,代码行数:26,代码来源:AccountController.cs

示例5: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:tosca,项目名称:Hyatt,代码行数:31,代码来源:AccountController.cs

示例6: ChangePassword

 public ActionResult ChangePassword()
 {
     var model = new ChangePasswordModel();
     model.Username = User.Identity.Name;
     var user = context.Accounts.FirstOrDefault(x => x.Username.Contains(model.Username));
     model.Email = user.Email;
     return View(model);
 }
开发者ID:dimparis,项目名称:computer-product-suggestion,代码行数:8,代码来源:AccountController.cs

示例7: TestChangePassword

        public void TestChangePassword()
        {
            string testUserName = "TestUserName";
            string testOldPassword = "TestOldPassword";
            string testNewPassword = "TestNewPassword";

            var changePasswordModel = new ChangePasswordModel
            {
                OldPassword = testOldPassword,
                NewPassword = testNewPassword
            };

            var accountController = new AccountController();

            //Stub HttpContext
            var stubHttpContext = new StubHttpContextBase();
            //Setup ControllerContext so AccountController will use our stubHttpContext
            accountController.ControllerContext = new ControllerContext(stubHttpContext,
                new RouteData(), accountController);

            //Stub IPrincipal
            var principal = new StubIPrincipal();
            principal.IdentityGet = () =>
            {
                var identity = new StubIIdentity { NameGet = () => testUserName };
                return identity;
            };
            stubHttpContext.UserGet = () => principal;

            RedirectToRouteResult redirectToRouteResult;
            //Scope the detours we're creating
            using (ShimsContext.Create())
            {
                ShimMembership.GetUserStringBoolean = (identityName, userIsOnline) =>
                {
                    Assert.AreEqual(testUserName, identityName);
                    Assert.AreEqual(true, userIsOnline);

                    var memberShipUser = new ShimMembershipUser();
                    //Sets up a detour for MemberShipUser.ChangePassword to our mocked implementation
                    memberShipUser.ChangePasswordStringString = (oldPassword, newPassword) =>
                    {
                        Assert.AreEqual(testOldPassword, oldPassword);
                        Assert.AreEqual(testNewPassword, newPassword);
                        return true;
                    };
                    return memberShipUser;
                };

                var actionResult = accountController.ChangePassword(changePasswordModel);
                Assert.IsInstanceOf(typeof(RedirectToRouteResult), actionResult);
                redirectToRouteResult = actionResult as RedirectToRouteResult;
            }
            Assert.NotNull(redirectToRouteResult);
            Assert.AreEqual("ChangePasswordSuccess", redirectToRouteResult.RouteValues["Action"]);
        }
开发者ID:RichCzyzewski,项目名称:NoninvasiveMVC4Testing,代码行数:56,代码来源:AccountsControllerTests.cs

示例8: ChangePassword

 public HttpResponseMessage ChangePassword(ChangePasswordModel model)
 {
     model.UserID = User.UserID;
     ActionOutput output = _userManager.ChangePassword(model);
     return Request.CreateResponse<ApiActionOutput>(new ApiActionOutput
     {
         Status = output.Status,
         Message = output.Message
     });
 }
开发者ID:jhakasjk,项目名称:BaseProject,代码行数:10,代码来源:UserController.cs

示例9: ChangePassword

        public void ChangePassword(ChangePasswordModel changePasswordModel)
        {
            var db = GetDbContext();

            var user = GetCurrentUser();
            user.Password = EncryptPassword(changePasswordModel.NewPassword);

            db.SubmitChanges();

            SendEmail("[email protected]", user.Email, "Iudico Notification", "Your passord has been changed.");
        }
开发者ID:supermuk,项目名称:iudico,代码行数:11,代码来源:DatabaseUserStorage.cs

示例10: ChangePassword

        public ActionResult ChangePassword(int id)
        {
            User user = userService.GetUserById(id);

             ChangePasswordModel model = new ChangePasswordModel()
             {
            User = user
             };

             return this.View("ChangePassword", model);
        }
开发者ID:aozora,项目名称:arashi,代码行数:11,代码来源:UsersController.cs

示例11: ChangePassword

        public ActionResult ChangePassword(string key)
        {
            var model = new ChangePasswordModel(key);

            if (model.Key != null)
            {
                return View(model);
            }

            return RedirectToAction("Login", new { returnUrl = "/" });
        }
开发者ID:codevlabs,项目名称:DirigoEdge,代码行数:11,代码来源:AccountController.cs

示例12: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                bool changePasswordSucceeded = true;
                try
                {
                    if (ModelState.IsValid && model.OldPassword != null)
                    {
                        int id = ((Session)Session["Session"]).UserID;
                        User oldUser = db.Users.Single(u => u.UserID == id);

                        string source = model.OldPassword;
                        using (MD5 md5Hash = MD5.Create())
                        {
                            Encryptor enc = new Encryptor();
                            string hash = enc.GetMd5Hash(md5Hash, source);
                            if (enc.VerifyMd5Hash(md5Hash, source, hash))
                            {
                                if (hash == oldUser.Password)
                                {
                                    source = model.NewPassword;
                                    hash = enc.GetMd5Hash(md5Hash, source);
                                    if (enc.VerifyMd5Hash(md5Hash, source, hash))
                                    {
                                        oldUser.Password = hash;
                                        db.Users.Attach(oldUser);
                                        db.ObjectStateManager.ChangeObjectState(oldUser, EntityState.Modified);
                                        db.SaveChanges();
                                        changePasswordSucceeded = true;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:rogerex,项目名称:shopnet,代码行数:54,代码来源:AccountController.cs

示例13: ShouldNotValidateModelWhenGetActionResult

        public void ShouldNotValidateModelWhenGetActionResult()
        {
            // arrange
            var invalidModel = new ChangePasswordModel {  };
            var controllerAction = new AccountController().Action(c => c.ChangePassword(invalidModel));
            var context = controllerAction.GetExecutionContext();

            // act
            controllerAction.GetActionResult(context);
            //assert
            context.ModelState.IsValid.Should().BeTrue();
        }
开发者ID:sandermvanvliet,项目名称:Xania.AspNet,代码行数:12,代码来源:LinqActionValidationTests.cs

示例14: ChangePassword

 public ActionResult ChangePassword(string Email)
 {
     var user = userRepository.GetUserProfile(Email);
     ChangePasswordModel dv = null;
     if (user != null)
     {
         dv = new ChangePasswordModel();
         dv.Id = user.Id;
         dv.OldPassword = user.Password;
     }
     return GetView(WebConstants.View_ChangePassword, dv);
     //return GetView(WebConstants.View_ChangePasswordPartial, dv);
 }
开发者ID:huutruongqnvn,项目名称:vnecoo01,代码行数:13,代码来源:UserController.cs

示例15: ChangePassword

        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid) {
                if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword)) {
                    return RedirectToAction("ChangePasswordSuccess");
                } else {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:jonneale,项目名称:Egg,代码行数:13,代码来源:AccountController.cs


注:本文中的ChangePasswordModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。