public async Task <bool> CreateAsync(Customer customer) { var isExsits = _accountRepository.IsEmailExistsAsync(customer.Email); if (isExsits.Result == false) { customer.PasswordSalt = Hashing.GetSalt(); customer.PasswordHash = Hashing.GenerateHash(customer.Password, customer.PasswordSalt); var isCreated = await _accountRepository.CreateAccountAsync(customer); if (isCreated == false) { throw new Exception("Creation failed"); } EmailVerification emailVerification = new EmailVerification() { Email = customer.Email, VerificationCode = GenerateRandomNo(1000, 9999), ExpirationTime = DateTime.Now.AddMinutes(60) }; await _verificationRepository.CreateEmailVerificationAsync(emailVerification); await _verificationService.SendVerificationCodeAsync(emailVerification); return(true); } return(false); }
public async Task <ActionResult <bool> > GenerateEmailVerificationAsync(string email) { if (String.IsNullOrEmpty(email) || !(email.Contains("@"))) { return(BadRequest("not valid email address")); } await _verificationService.SendVerificationCodeAsync(email); return(Ok()); }