本文整理汇总了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);
}
示例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 });
}
示例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();
}
示例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);
}