public async Task <IActionResult> AddTwoFactorPhoneAuthentication(AddTwoFactorPhoneAuthenticationRequest request) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } Result <IEnumerable <string> > verifyResult = await _twoFactorAuthService.VerifyPhoneTwoFactorCode(GetUserId(), request); if (verifyResult.Failure) { SaveTempData(PHONE_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(verifyResult)); return(RedirectToAction(nameof(AddTwoFactorEmailAuthentication))); } SaveTempData(RECOVERY_CODES_KEY, verifyResult.Value); return(RedirectToAction(nameof(RecoveryCodesView))); }
public Task <Result <IEnumerable <string> > > VerifyPhoneTwoFactorCode(string userId, AddTwoFactorPhoneAuthenticationRequest request) { ValidationResult validationResult = _addPhoneTwoFactorValidator.Validate(request); if (!validationResult.IsValid) { _logger.LogError($"Verification failed."); return(Task.FromResult(Result.Fail <IEnumerable <string> >(ResultUtils.ToResultError(validationResult.Errors)))); } return(AddTwoFactorAuthentication(userId, TwoFactorAuthenticationType.Email, request.Token)); }