本文整理汇总了C#中ChangePasswordViewModel类的典型用法代码示例。如果您正苦于以下问题:C# ChangePasswordViewModel类的具体用法?C# ChangePasswordViewModel怎么用?C# ChangePasswordViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChangePasswordViewModel类属于命名空间,在下文中一共展示了ChangePasswordViewModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ChangePassword
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var result = await this.UserManager
.ChangePasswordAsync(
User.Identity.GetUserId(),
model.OldPassword,
model.NewPassword);
if (result.Succeeded)
{
var user = await this.UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null)
{
await this.SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
}
return this.RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
}
this.AddErrors(result);
return this.View(model);
}
开发者ID:vassildinev,项目名称:ASP.NET-MVC,代码行数:27,代码来源:ManageController.cs
示例2: ChangePassword
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
if (model == null) throw new ArgumentNullException("model");
if (ModelState.IsValid)
{
bool changePasswordSucceeded;
try
{
changePasswordSucceeded = WebSecurity.ChangePassword(User.Identity.Name, model.OldPassword,
model.NewPassword);
}
catch (Exception)
{
changePasswordSucceeded = false;
}
if (changePasswordSucceeded)
{
TempData["SuccessMessage"] = "Пароль успешно изменен";
}
else
{
ModelState.AddModelError("", "Неправильный текущий пароль или недопустимый новый пароль.");
}
}
return View(model);
}
开发者ID:vitalzhuravkov,项目名称:FileUploader,代码行数:28,代码来源:AccountController.cs
示例3: ChangePassword
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
if (this.ModelState.IsValid && this.authentication.ChangePassword(this.authentication.CurrentUserName, model.OldPassword, model.NewPassword))
{
return this.RedirectToAction("ChangePassword", new { saveSuccessful = true });
}
this.ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
return this.View(model);
}
开发者ID:marijngiesen,项目名称:qoam,代码行数:11,代码来源:AccountController.cs
示例4: ChangePasswordAction_WithValidValuesReturnsRedirectToRoute
public void ChangePasswordAction_WithValidValuesReturnsRedirectToRoute()
{
// Arrange
var controller = CreateAccountController();
var changePasswordView = new ChangePasswordViewModel { UserName = "TestUser", OldPassword = "password", NewPassword = "pa33word" };
// Act
var result = controller.ChangePassword(changePasswordView);
// Assert
Assert.IsInstanceOf<RedirectToRouteResult>(result, "RedirectToRouteResult not returned.");
}
开发者ID:Emon0407,项目名称:WebConnection,代码行数:12,代码来源:AccountControllerTest.cs
示例5: ChangePasswordAction_ReturnsViewIfFails
public void ChangePasswordAction_ReturnsViewIfFails()
{
// Arrange
var controller = CreateAccountController();
var changePasswordView = new ChangePasswordViewModel { UserName = "wrong", OldPassword = "wrong", NewPassword = "pa33word" };
// Act
var result = controller.ChangePassword(changePasswordView);
var viewResult = (ViewResult)result;
// Assert
Assert.IsInstanceOf<ViewResult>(result, "ViewResult not returned.");
Assert.AreSame(changePasswordView, viewResult.ViewData.Model, "User and Model are not the same");
Assert.AreEqual(false, viewResult.ViewData.ModelState.IsValid);
}
开发者ID:Emon0407,项目名称:WebConnection,代码行数:15,代码来源:AccountControllerTest.cs
示例6: ChangePasswordAction_WithValidValuesUpdatesPassword
public void ChangePasswordAction_WithValidValuesUpdatesPassword()
{
// Arrange
var controller = CreateAccountController();
var user = new LoginViewModel { UserName = "TestUser", Password = "password" };
var changePasswordView = new ChangePasswordViewModel { UserName = "TestUser", OldPassword = "password", NewPassword = "pa33word" };
// Act
var result = controller.ChangePassword(changePasswordView);
// Assert
//Assert.IsInstanceOf<RedirectToRouteResult>(result, "Redirect to route not returned.");
//Assert.AreEqual("Customers", redirectresult.RouteValues["controller"]);
//Assert.AreEqual("Index", redirectresult.RouteValues["action"]);
}
开发者ID:Emon0407,项目名称:WebConnection,代码行数:16,代码来源:AccountControllerTest.cs
示例7: ChangePasswordAction_ReturnsViewIfInvalidModelState
public void ChangePasswordAction_ReturnsViewIfInvalidModelState()
{
// Arrange
var controller = CreateAccountController();
var changePasswordView = new ChangePasswordViewModel { UserName = "TestUser", OldPassword = "password", NewPassword = "pa33word" };
controller.ModelState.AddModelError("*", "Invalid model state.");
// Act
var result = controller.ChangePassword(changePasswordView);
// Assert
Assert.IsInstanceOf<ViewResult>(result, "ViewResult not returned.");
var viewResult = (ViewResult)result;
Assert.AreSame(changePasswordView, viewResult.ViewData.Model, "User and Model are not the same");
}
开发者ID:Emon0407,项目名称:WebConnection,代码行数:16,代码来源:AccountControllerTest.cs
示例8: Password
public async Task<IActionResult> Password(ChangePasswordViewModel viewModel)
{
if (!ModelState.IsValid)
return RedirectToAction("Password");
return await _userService.SetNewPasswordAsync(UserId, viewModel.ActualPassword, viewModel.NewPassword)
.Execute(
onSuccess: () =>
{
Notify(FlashNotificationType.Success, "Password has been changed.");
return RedirectToAction("Index");
},
onFailure: ex =>
{
Notify(FlashNotificationType.Error, ex.Message);
return RedirectToAction("Password");
});
}
开发者ID:thecorrado,项目名称:Warden,代码行数:18,代码来源:SettingsController.cs
示例9: ChangePassword
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
model.UserName = User.Identity.Name;
if (ModelState.IsValid)
{
if (MembershipService.ChangePassword(model.UserName, model.OldPassword, model.NewPassword))
{
return RedirectToAction("ChangePasswordSuccess");
}
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
}
// If we got this far, something failed, redisplay form
ViewBag.PasswordLength = MembershipService.MinPasswordLength;
return View(model);
}
开发者ID:Emon0407,项目名称:WebConnection,代码行数:18,代码来源:AccountController.cs
示例10: ChangePassword
public JsonResult ChangePassword(ChangePasswordViewModel changePasswordView)
{
if (!ModelState.IsValid)
{
return Json(new { Success = false, Message = Resources.ValidationFailed });
}
var command = new ChangePasswordCommand(UserInfo.Id, changePasswordView.CurrentPassword, changePasswordView.NewPassword);
var result = ExecuteCommand(command);
if (result)
{
TempData[ViewDataKeys.Message] = new SuccessMessage(Resources.PasswordChangeSuccess);
return Json(new { Success = true });
}
else
{
return Json(new { Success = false, Message = Resources.IncorrectCurrentPassword });
}
}
开发者ID:techsavy,项目名称:AtYourService,代码行数:21,代码来源:AccountsController.cs
示例11: ChangePassword
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel changePasswordViewModel)
{
if (!ModelState.IsValid)
return View(changePasswordViewModel);
var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId<int>(), changePasswordViewModel.CurrentPassword, changePasswordViewModel.NewPassword);
if (result.Succeeded)
{
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId<int>());
if (user != null)
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
TempData["Message"] = ActionMessage.ChangePasswordSuccess;
}
return RedirectToAction("changepassword", "action");
}
AddErrors(result);
return View(changePasswordViewModel);
}
开发者ID:thieunq92,项目名称:orientalsails.v2013.mvc,代码行数:21,代码来源:ActionController.cs
示例12: ChangePassword
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
if (this.ModelState.IsValid)
{
var request = new ChangePasswordRequest
{
UserName = "???",
OldPassword = model.OldPassword,
NewPassword = model.NewPassword
};
var response = this.accountService.ChangePassword(request);
if (response.Status == StatusCode.OK)
{
this.TempData["SuccessMessage"] = "You have successfully changed your password.";
return this.RedirectToAction("Index");
}
else
{
this.ViewBag.DisplaySummary = "yes";
this.ModelState.AddModelError(string.Empty, "Your old password has not been recognised. Please try again.");
}
}
return this.View();
}
开发者ID:porl88,项目名称:Website-MVC,代码行数:26,代码来源:AccountController.cs
示例13: ChangePassword
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
IdentityResult result = await _userManager.ChangePasswordAsync(User.Identity.GetUserId2<ObjectId>()
, model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
var user = await _userManager.FindByIdAsync(User.Identity.GetUserId2<ObjectId>());
if (user != null)
{
await SignInAsync(user, isPersistent: false);
}
return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
}
AddErrors(result);
return View(model);
}
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:20,代码来源:ManageController.cs
示例14: ChangePassword
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
string strError = string.Empty;
try
{
if (ModelState.IsValid)
{
await ParseUser.RequestPasswordResetAsync(model.Email);
model.Message = Strings.GetLocalizedString(Strings.ChangePasswordSuccessMessage);
model.IsSuccess = true;
model.CaptchaOK = true;
}
else
{
model.CaptchaOK = false;
}
}
catch (Exception ex)
{
strError = ex.ToString();
model.IsSuccess = false;
}
if (!string.IsNullOrEmpty(strError))
{
await ParseLogger.Log("Change Password", strError);
model.Message = MyMentorResources.validationChangePasswordError;
return View(model);
}
return View(model);
}
开发者ID:natan1957,项目名称:mymentor-portal,代码行数:31,代码来源:AccountController.cs
示例15: ChangePassword
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var result = await this.UserManager.ChangePasswordAsync(this.User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId());
if (user != null)
{
await this.SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
}
this.AddToastMessage("Congratulations", "Your password has been changed.", ToastType.Success);
return this.RedirectToAction<HomeController>(c => c.Index());
}
this.AddErrors(result);
return this.View(model);
}
开发者ID:TomaNikolov,项目名称:EventSystem,代码行数:23,代码来源:ManageController.cs
示例16: ChangePassword
public async Task<IActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await GetCurrentUser();
if (user != null)
{
var result = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToAction(nameof(Microsoft.EntityFrameworkCore.Metadata.Internal.Index), new { Message = ManageMessageId.ChangePasswordSuccess });
}
AddErrorsToModelState(result);
return View(model);
}
return RedirectToAction(nameof(Microsoft.EntityFrameworkCore.Metadata.Internal.Index), new { Message = ManageMessageId.Error });
}
开发者ID:ChrisDobby,项目名称:allReady,代码行数:24,代码来源:ManageController.cs
示例17: ChangePassword
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
ResponseModel response = new ResponseModel();
UserInfo user = _userInfoService.GetById(model.Id);
user.Password = model.Password.ToMd5String();
_userInfoService.Update(user);
_unitOfWork.Commit();
response.Msg = "重置密码成功!";
response.Success = true;
response.RedirectUrl = string.Empty;
return Json(response, JsonRequestBehavior.AllowGet);
}
开发者ID:btcamp,项目名称:Btcamp.Crowdfunding,代码行数:12,代码来源:UserController.cs
示例18: ChangePassword
public async Task<IActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await GetCurrentUserAsync();
if (user != null)
{
var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
}
AddErrors(result);
return View(model);
}
return RedirectToAction("Index", new { Message = ManageMessageId.Error });
}
开发者ID:GustavoSchuler,项目名称:BookStore-.NET-Core,代码行数:20,代码来源:ManageController.cs
示例19: OnSelectedMenuItem
private void OnSelectedMenuItem()
{
if (SelectedMenuItem == MenuResources.ChangePassword)
{
if (ChangePasswordViewModel == null)
ChangePasswordViewModel = new ChangePasswordViewModel(this.Messenger, this.UserLogin)
{
ParentViewModel = this
};
DetailSectionViewModel = ChangePasswordViewModel;
return;
}
}
开发者ID:ruisebastiao,项目名称:WPF-MVVM-With-Entity-Framework,代码行数:14,代码来源:SettingsViewModel.cs
示例20: ChangePassword
//[ValidateAntiForgeryToken]
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
if (ModelState.IsValid)
{
var userID = GetCurrentUserID();
var result = await this.UserManager.ChangePasswordAsync(userID, model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
var user = await GetCurrentUserAsync();
user.ChangedPassword = true;
var updateUserResult = await this.UserManager.UpdateAsync(user);
if (result.Succeeded)
{
return Json("OK", JsonRequestBehavior.AllowGet);
}
else
{
return JsonMessage.BadRequestJsonResult(updateUserResult.Errors);
}
}
else
{
return JsonMessage.BadRequestJsonResult(result.Errors);
}
}
return JsonMessage.BadRequestJsonResult(ModelState.Values.SelectMany(x => x.Errors));
}
开发者ID:AntonHuang,项目名称:WebAppEF6,代码行数:29,代码来源:AccountController.cs
注:本文中的ChangePasswordViewModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论