public bool EditUserEmail(ProfileEmailEditViewModel model) { if (!string.IsNullOrEmpty(model.Email)) { var userManager = UserManager.GetManager(SecurityManager.GetUser(model.UserId).ProviderName); var user = userManager.GetUser(model.UserId); if (!userManager.ValidateUser(user, model.Password)) { return(false); } if (user.Email != model.Email) { user.Email = model.Email; if (this.AllowCurrentProfileUpdates && SecurityManager.GetCurrentUserId() == user.Id) { using (new ElevatedModeRegion(userManager)) { userManager.SaveChanges(); } } else { userManager.SaveChanges(); } return(true); } return(false); } return(false); }
public bool EditUserEmail(ProfileEmailEditViewModel model) { if (!string.IsNullOrEmpty(model.Email)) { var userManager = UserManager.GetManager(SecurityManager.GetUser(model.UserId).ProviderName); var user = userManager.GetUser(model.UserId); if (!userManager.ValidateUser(user, model.Password)) { return(false); } if (user.Email != model.Email) { user.Email = model.Email; userManager.SaveChanges(); return(true); } return(false); } return(false); }