public async Task <List <ValidationResult> > ConfirmPhoneNumber(ConfirmationEmailQueryModel model) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { results.Add(new ValidationResult($"User with {model.Email} does not exist")); return(results); } var result = await _userManager.VerifyChangePhoneNumberTokenAsync(user, model.Token, user.PhoneNumber); if (result) { user.PhoneNumberConfirmed = true; await _userManager.UpdateAsync(user); } if (!result) { results.Add(new ValidationResult($"Failed to verify user phoneNumber {user.PhoneNumber ?? ""}")); return(results); } return(results); }
public async Task <List <ValidationResult> > ConfirmEmail(ConfirmationEmailQueryModel model) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { results.Add(new ValidationResult($"User with {model.Email} does not exist")); return(results); } var result = await _userManager.ConfirmEmailAsync(user, model.Token); if (!result.Succeeded) { results.Add(new ValidationResult(string.Join(";", result.Errors.Select(x => x.Code)))); return(results); } //Activate User user.Activated = true; await _userManager.UpdateAsync(user); //Send PasswordReset Email await RequestPasswordReset(user.Email); return(results); }