public async Task <bool> ConfirmEmailAsync(UserDTO userDTO, string hash) { string hashConfirmData = EmailConfirmHelper.GetHash(userDTO.Id, userDTO.Verification, userDTO.Email); bool isHashEqual = EmailConfirmHelper.EqualHash(hash, hashConfirmData); if (!isHashEqual) { return(false); } var existedUser = await database.UserRepository.GetByIdAsync(userDTO.Id); existedUser.Verification = true; var updatedUser = database.UserRepository.Update(existedUser); bool isSave = await database.SaveAsync(); return(isSave); }
public async Task <bool> ConfirmEmailAsync(UserDTO userDTO, string hash) { string hashConfirmData = EmailConfirmHelper.GetHash(userDTO.Id, userDTO.IsEmailValid, userDTO.Email); bool isHashEqual = EmailConfirmHelper.EqualHash(hash, hashConfirmData); if (isHashEqual) { var existedUser = await database.UserRepository.GetEntityByIdAsync(userDTO.Id); existedUser.IsEmailValid = true; var updatedUser = database.UserRepository.UpdateEntity(existedUser); bool isSave = await database.SaveAsync(); return(isSave); } return(false); }