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


C# SetPasswordViewModel类代码示例

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


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

示例1: SetPassword

        public async Task<ActionResult> SetPassword(SetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                if (result.Succeeded)
                {
                    var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                    if (user != null)
                    {
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    }
                    return RedirectToAction("Index", new { Message = ManageMessageId.SetPasswordSuccess });
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:archlicher,项目名称:ASP.NET,代码行数:20,代码来源:ManageController.cs

示例2: SetPassword

        public async Task<IActionResult> SetPassword(SetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var user = await GetCurrentUserAsync();
            if (user != null)
            {
                var result = await _userManager.AddPasswordAsync(user, model.NewPassword);
                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent: false);
                    return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetPasswordSuccess });
                }
                AddErrors(result);
                return View(model);
            }
            return RedirectToAction(nameof(Index), new { Message = ManageMessageId.Error });
        }
开发者ID:PMelia07,项目名称:Personal-Website,代码行数:21,代码来源:ManageController.cs

示例3: SetPassword

		public ActionResult SetPassword(SetPasswordViewModel setPasswordViewModel)
		{
			if(!this.ValidateAndAppendMessages(setPasswordViewModel))
			{
				return View(new SetPasswordViewModel { AuthToken = setPasswordViewModel.AuthToken });
			}

			// Check if Auth Token is Expired
			if (this.UserLoginService.AuthTokenIsExired(setPasswordViewModel.AuthToken))
			{
				return this.Issue404();
			}

			using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork())
			{
				try
				{
					this.UserLoginService.SetPasswordUsingAuthToken(setPasswordViewModel.AuthToken, setPasswordViewModel.Password);
					unitOfWork.Commit();

					this.ForwardMessage(new SuccessMessage { Text = "Your password has been reset.  You may now login using your new password." });

					return RedirectToAction("login");
				}
				catch (Exception ex)
				{
					this.LogHandledException(ex);
					unitOfWork.Rollback();

					this.AppendMessage(new ErrorMessage { Text = GenericMessages.ErrorMessage });
				}
			}

			return View();
		}
开发者ID:AnthonyYates,项目名称:brewgr.com,代码行数:35,代码来源:AuthController.cs

示例4: SetPassword

        public async Task<ActionResult> SetPassword(SetPasswordViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var result = await this.UserManager.AddPasswordAsync(this.User.Identity.GetUserId(), model.NewPassword);
                if (result.Succeeded)
                {
                    var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId());
                    if (user != null)
                    {
                        await this.SignInManager.SignInAsync(user, false, false);
                    }
                    return this.RedirectToAction("Profile", new { Message = ManageMessageId.SetPasswordSuccess });
                }
                this.AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return this.View(model);
        }
开发者ID:iliankostov,项目名称:ASP.NET-MVC,代码行数:20,代码来源:UsersController.cs


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