• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ResetPasswordViewModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ResetPassword

 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction("ResetPasswordConfirmation", "User");
     }
     if (model.Password != model.ConfirmPassword)
     {
         ModelState.AddModelError("", "Password and Confirm Password Mismatch");
         return View();
     }
     var result = await UserManager.ResetPasswordAsync(user.Id,  model.Code.Replace(" ", "+"), model.Password); 
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "User");
     }
     AddErrors(result);
     return View();
 }
开发者ID:jdsv650,项目名称:BwareApp_API,代码行数:25,代码来源:UserController.cs


示例2: ResetPassword

        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
                return Json(new ServiceOperationResult(false) {Message = Main.InvalidForm});

            return Json(PiServices.UserService.ChangePassword(model));
        }
开发者ID:jacbar,项目名称:Runner,代码行数:7,代码来源:AccountController.cs


示例3: TryResetPassword

        private ActionResult TryResetPassword(ResetPasswordViewModel model)
        {
            try
            {
                var tokenValidation = this.Service.ValidateResetToken(model.ResetToken);
                if (tokenValidation.Type == ResetToken.ResetType.Both)
                {
                    if (!this.Service.IsPasswordStrengthPassed(model.Password))
                        throw new WeakPasswordException();

                    SavePasswordToSession(model.Password);
                    return RedirectToAction("ResetSecurePhrase", new { resetToken = model.ResetToken });
                }

                this.Service.FinishResetPassword(model.ResetToken, model.Password);
                return RedirectToAction("ResetPasswordConfirmation");
            }
            catch (InvalidResetTokenException)
            {
                AddModelStateError(GlobalStrings.ResetTokenIsInvalid);
            }
            catch (WeakPasswordException)
            {
                AddModelStateError(GlobalStrings.WeakPassword);
            }
            catch (Exception)
            {
                AddModelStateError(GlobalStrings.SomethingWentWrong);
            }

            return View(model);
        }
开发者ID:Cognite-Soft,项目名称:ARB_2016_V2,代码行数:32,代码来源:AccountControllerResetPassword.cs


示例4: ResetPassword

        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
                return TryResetPassword(model);

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:Cognite-Soft,项目名称:ARB_2016_V2,代码行数:8,代码来源:AccountControllerResetPassword.cs


示例5: ResetPasswordView

        private ActionResult ResetPasswordView(string resetToken)
        {
            var model = new ResetPasswordViewModel()
            {
                ResetToken = resetToken,
            };

            return View(model);
        }
开发者ID:Cognite-Soft,项目名称:ARB_2016_V2,代码行数:9,代码来源:AccountControllerResetPassword.cs


示例6: ChangePassword

        public ServiceOperationResult ChangePassword(ResetPasswordViewModel model)
        {
            User user = UserRepository.GetUser(UserName);
            if(user.Password != HashHelpers.GetSHA256Hash(model.OldPassword, user.Salt.ToString()))
            {
                return new ServiceOperationResult(false) {Message = Main.OldPasswordInvalid};
            }

            return Mapper.Map<DataResult, ServiceOperationResult>(UserRepository.ChangePassword(user, model.NewPassword));
        }
开发者ID:jacbar,项目名称:Runner,代码行数:10,代码来源:UserService.cs


示例7: ResetPassword

        public ActionResult ResetPassword(string userName)
        {
            
            var model = new ResetPasswordViewModel()
                            {
                                Username = userName,
                                NewPassword = "123456" // generate
                            };

            // reset the password
            return View(model);
        }
开发者ID:shaimuli,项目名称:Simple.SAMS,代码行数:12,代码来源:AccountController.cs


示例8: ResetPassword

        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if(ModelState.IsValid)
            {
                membershipService.ResetPassword(model.Username);
                membershipService.Commit();

                SuccessMessage(FormMessages.AccountResetPassword);
                return RedirectToAction("Index", "Home");
            }

            return View(model);
        }
开发者ID:philjhale,项目名称:TeessideBasketballLeague,代码行数:13,代码来源:AccountController.cs


示例9: ResetPassword

        public ActionResult ResetPassword(string code)
        {
            if (code == null)
            {
                return View("Error");
            }

            ResetPasswordViewModel md = new ResetPasswordViewModel()
            {
                Code = code
            };

            return View(md);
        }
开发者ID:jcingroup,项目名称:C381421_ChengShen,代码行数:14,代码来源:MNGLoginController.cs


示例10: Index

        public ActionResult Index(ResetPasswordViewModel rp)
        {
            //get the email from the URL
            string email = Request.QueryString["user_email"];

            //collect the data from the form
            if (ModelState.IsValid)
            {

                if (!SecurityHelper.StripHTML(rp.Password).Equals(SecurityHelper.StripHTML(rp.ConfPassword))) //the passwords have to match
                {
                    ViewBag.Message = "The two passwords have to match.";
                    return View("ResetPassword");
                }
                else //made it through both checks
                {

                    var collectUser = (
                        from usr in db.Users
                        where usr.email.Equals(SecurityHelper.StripHTML(email))
                        select usr
                        ).First();

                    collectUser.password = AuthenticationHelper.ENCRYPT_ME(SecurityHelper.StripHTML(rp.Password));

                    try
                    {
                        db.SaveChanges();
                        return RedirectToAction("Index", "Login");
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = "Something weird happened. Try again.";
                        return View("ResetPassword");
                    }

                }

            }
            else
            {
                ViewBag.Message = "You have to fill in both fields.";
                return View("ResetPassword");
            }
        }
开发者ID:jotsb,项目名称:CST-Life-No-More-C--MVC4,代码行数:45,代码来源:ResetPasswordController.cs


示例11: ResetPassword

        public ActionResult ResetPassword(int userId, string token)
        {
            var model = new ResetPasswordViewModel()
            {
                Token = token,
                UserId = userId
            };

            return token == null ? View("Error") : View(model);
        }
开发者ID:inatoff,项目名称:ACTS_Site,代码行数:10,代码来源:AccountController.cs


示例12: ResetPassword

        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null)
                {
                    ModelState.AddModelError("", "找不到用户。");
                    return View();
                }
                IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
                if (result.Succeeded)
                {
                    return RedirectToAction("ResetPasswordConfirmation", "Account");
                }
                else
                {
                    AddErrors(result);
                    return View();
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:25,代码来源:AccountController.cs


示例13: ResetPassword

 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         return this.View(model);
     }
     var user = await this.UserManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return this.RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await this.UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         return this.RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     this.AddErrors(result);
     return this.View();
 }
开发者ID:ASP-MVC,项目名称:Twitter-Like,代码行数:20,代码来源:AccountController.cs


示例14: ResetPassword

        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null)
                {
                    ModelState.AddModelError("", "Es wurde kein Benutzer gefunden.");
                    return View();
                }
                IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
                if (result.Succeeded)
                {
                    return RedirectToAction("ResetPasswordConfirmation", "Account");
                }
                else
                {
                    AddErrors(result);
                    return View();
                }
            }

            // Wurde dieser Punkt erreicht, ist ein Fehler aufgetreten. Formular erneut anzeigen.
            return View(model);
        }
开发者ID:GundlackFelixDEV,项目名称:ASP.NET_TUTS,代码行数:25,代码来源:AccountController.cs


示例15: ResetPassword

        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null)
                {
                    ModelState.AddModelError("", "No se encontró ningún usuario.");
                    return View();
                }
                IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
                if (result.Succeeded)
                {
                    return RedirectToAction("ResetPasswordConfirmation", "Account");
                }
                else
                {
                    AddErrors(result);
                    return View();
                }
            }

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


示例16: ajax_ResetPassword

        public async Task<string> ajax_ResetPassword(ResetPasswordViewModel model)
        {
            ResultInfo rAjaxResult = new ResultInfo();

            try
            {
                if (ModelState.IsValid)
                {
                    var user = await UserManager.FindByEmailAsync(model.Email);
                    if (user == null)
                    {
                        rAjaxResult.result = false;
                        rAjaxResult.message = Resources.Res.Log_Err_NoThisUser;
                        return defJSON(rAjaxResult);
                    }
                    IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
                    if (result.Succeeded)
                    {
                        rAjaxResult.result = true;
                        return defJSON(rAjaxResult);
                    }
                    else
                    {
                        rAjaxResult.message = String.Join(":", result.Errors);
                        rAjaxResult.result = false;
                        return defJSON(rAjaxResult);
                    }
                }
                else
                {
                    List<string> errMessage = new List<string>();
                    foreach (ModelState modelState in ModelState.Values)
                        foreach (ModelError error in modelState.Errors)
                            errMessage.Add(error.ErrorMessage);

                    rAjaxResult.message = String.Join(":", errMessage);
                    rAjaxResult.result = false;
                    return defJSON(rAjaxResult);
                }
            }
            catch (Exception ex)
            {
                rAjaxResult.result = false;
                rAjaxResult.message = ex.Message;
                return defJSON(rAjaxResult);
            }
        }
开发者ID:jcingroup,项目名称:C501602_ATEK,代码行数:47,代码来源:LoginController.cs


示例17: ResetPassword

 public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await _userManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
     }
     var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);
     if (result.Succeeded)
     {
         return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
     }
     AddErrors(result);
     return View();
 }
开发者ID:usedflax,项目名称:flaxbox,代码行数:20,代码来源:AccountController.cs


示例18: ResetPassword

 public ActionResult ResetPassword(string code, Guid userId, string email)
 {
     var model = new ResetPasswordViewModel() {Email=email, Code=code };
     return code == null ? View("Error") : View();
 }
开发者ID:crazycry0gen,项目名称:Aroma-Violet,代码行数:5,代码来源:AccountController.cs


示例19: HandleResetPassword

        public ActionResult HandleResetPassword(ResetPasswordViewModel model)
        {
            var membershipService = ApplicationContext.Current.Services.MemberService;

            if (!ModelState.IsValid)
            {
                return CurrentUmbracoPage();
            }

            //Get member from email
            var resetMember = membershipService.GetByEmail(model.EmailAddress);

            //Ensure we have that member
            if (resetMember != null)
            {
                //Get the querystring GUID
                var resetQueryString = Request.QueryString["resetGUID"];

                //Ensure we have a vlaue in QS
                if (!string.IsNullOrEmpty(resetQueryString))
                {
                    //See if the QS matches the value on the member property
                    if (resetMember.Properties["resetGUID"].Value.ToString() == resetQueryString)
                    {

                        //Got a match, now check to see if the 15min window hasnt expired
                        DateTime expiryTime = DateTime.ParseExact(resetQueryString, "ddMMyyyyHHmmssFFFF", null);

                        //Check the current time is less than the expiry time
                        DateTime currentTime = DateTime.Now;

                        //Check if date has NOT expired (been and gone)
                        if (currentTime.CompareTo(expiryTime) < 0)
                        {
                            //Got a match, we can allow user to update password
                            //resetMember.RawPasswordValue.Password = model.Password;
                            membershipService.SavePassword(resetMember, model.Password);

                            //Remove the resetGUID value
                            resetMember.Properties["resetGUID"].Value = string.Empty;

                            //Save the member
                            membershipService.Save(resetMember);

                            return Redirect("/login");
                        }
                        else
                        {
                            //ERROR: Reset GUID has expired
                            ModelState.AddModelError("ResetPasswordForm.", "Reset GUID has expired");
                            return CurrentUmbracoPage();
                        }
                    }
                    else
                    {
                        //ERROR: QS does not match what is stored on member property
                        //Invalid GUID
                        ModelState.AddModelError("ResetPasswordForm.", "Invalid GUID");
                        return CurrentUmbracoPage();
                    }
                }
                else
                {
                    //ERROR: No QS present
                    //Invalid GUID
                    ModelState.AddModelError("ResetPasswordForm.", "Invalid GUID");
                    return CurrentUmbracoPage();
                }
            }

            return RedirectToCurrentUmbracoPage();
        }
开发者ID:KrisJanssen,项目名称:Umbraco7-Standard-Membership,代码行数:72,代码来源:AuthSurfaceController.cs


示例20: ResetPassword

 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Не показывать, что пользователь не существует
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     AddErrors(result);
     return View();
 }
开发者ID:akhroponiuk,项目名称:NewFolder,代码行数:20,代码来源:AccountController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ResidualStopCriterium类代码示例发布时间:2022-05-24
下一篇:
C# Requisition类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap