public void Add(string userName, string barcode, string password, string firstName, int homeBranchID, int roleID, string email, bool isActive, bool canApproveDocument) { Employee emp = new Employee(); emp.UserName = userName; emp.Barcode = barcode; emp.FirstName = firstName; emp.HomeBranchID = homeBranchID; emp.RoleID = roleID; emp.Email = email; emp.IsActive = isActive; emp.CanApproveDocument = canApproveDocument; EntityHelper.SetAuditFieldForInsert(emp, principal.Identity.Name); context.Add(emp); var userAtBranch = new UserAtBranch() { BranchID = homeBranchID, UserName = userName }; context.Add(userAtBranch); context.SaveChanges(); securityProvider.ChangePassword(userName, password); }
public void ChangePassword() { //given var me = SeedData.CreateAdminUser(Context); var dummyUser = SeedData.CreateUser(Context, "Terminator", "Asta la vista"); ISecurityProvider provider = new SecurityProvider(Context, me); //when var setNewPassword = provider.ChangePassword(dummyUser.Id, "John Connor"); //then setNewPassword.ShouldBeTrue(); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { if (securityProvider.ValidateUser(CurrentUserName, model.OldPassword)) { securityProvider.ChangePassword(CurrentUserName, model.NewPassword); return(RedirectToAction("ChangePasswordConfirmation")); } ModelState.AddModelError(this.GetType().FullName, "Unable to validate current password"); } return(RedirectToAction("ChangePassword")); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { if (securityProvider.ValidateUser(CurrentUserName, model.OldPassword)) { securityProvider.ChangePassword(CurrentUserName, model.NewPassword); return(RedirectToAction("ChangePasswordSuccess")); } else { TempData["message"] = "Password lama salah."; RedirectToAction("ChangePassword"); } } return(RedirectToAction("ChangePassword")); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { if (securityProvider.ValidateUser(CurrentUserName, model.OldPassword)) { securityProvider.ChangePassword(CurrentUserName, model.NewPassword); ModelState.Clear(); return(RedirectToAction("ChangePasswordSuccess")); } else { ModelState.AddModelError("", "Current/old password is invalid"); RedirectToAction("ChangePassword"); } } return(RedirectToAction("ChangePassword")); }
public ActionResult ChangePassword(FormCollection form, ChangePasswordViewModel model) { if (ModelState.IsValid) { try { if (securityProvider.ValidateUser(User.Identity.Name, model.NewPassword)) { securityProvider.ChangePassword(User.Identity.Name, model.NewPassword); return(RedirectToAction("ChangePasswordSuccess")); } ModelState.AddModelError(String.Empty, "Old password is invalid."); } catch (Exception ex) { ModelState.AddModelError(String.Empty, ex.Message); Logger.ErrorException(ex.Message, ex); } } return(RedirectToAction("ChangePassword")); }