public async Task <User> ModifyEmail(string userId, string newEmail) { var user = await userManager.FindByIdAsync(userId); if (user == null) { throw new DbModelNullException(ExceptionMessageConstants.NullObject); } if (UserRepositoryExtension.ValidateEmail(newEmail)) { user.Email = newEmail; await db.SaveChangesAsync(); return(user); } throw new DbModelParamFormatException("Nem megfelelő formátumú email."); }
public async Task <User> ModifyPassword(string userId, string newPassword) { var user = await userManager.FindByIdAsync(userId); if (user == null) { throw new DbModelNullException(ExceptionMessageConstants.NullObject); } bool valid = await UserRepositoryExtension.ValidatePassword(newPassword, userManager, user); if (valid) { await userManager.AddPasswordAsync(user, newPassword); await db.SaveChangesAsync(); return(user); } throw new DbModelParamFormatException("Nem megfelelő a jelszó."); }