public ActionResult UpdateUserInfo(string currentPassword, string newPassword, string confirmPassword, string email, string firstName, string lastName) { ViewData["PasswordLength"] = MembershipService.MinPasswordLength; if (!ValidateUserInfo(currentPassword, newPassword, confirmPassword, email)) { return(View()); } try { var changePasswordResult = MembershipService.ChangePassword(User.Identity.Name, currentPassword, newPassword); MembershipService.UpdateUserEMial(User.Identity.Name, email); if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService))) { var data = new TableStorageMembershipProvider.AdditionalUserData(firstName, lastName); ((AccountMembershipService)MembershipService).SetUserAdditionalData(User.Identity.Name, data); } if (changePasswordResult) { return(RedirectToAction("About", "Home")); } ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid."); return(View()); } catch { ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid."); return(View()); } }
public void SetUserAdditionalData(string userName, TableStorageMembershipProvider.AdditionalUserData data) { if (_provider.GetType().IsAssignableFrom(typeof(TableStorageMembershipProvider))) { ((TableStorageMembershipProvider)_provider).SetUserAdditionalData(userName, data); } }
public ActionResult UpdateUserInfo(string currentPassword, string newPassword, string confirmPassword, string email, string firstName, string lastName) { ViewData["PasswordLength"] = MembershipService.MinPasswordLength; if (!ValidateUserInfo(currentPassword, newPassword, confirmPassword, email)) { return View(); } try { var changePasswordResult = MembershipService.ChangePassword(User.Identity.Name, currentPassword, newPassword); MembershipService.UpdateUserEMial(User.Identity.Name, email); if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService))) { var data = new TableStorageMembershipProvider.AdditionalUserData(firstName, lastName); ((AccountMembershipService)MembershipService).SetUserAdditionalData(User.Identity.Name, data); } if (changePasswordResult) { return RedirectToAction("About", "Home"); } ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid."); return View(); } catch { ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid."); return View(); } }