/// <summary> /// Verifies email, if <paramref name="verificationCode"/> is correct. /// </summary> /// <param name="verificationCode"></param> /// <returns></returns> public async Task <IdentityResult> VerifyPhoneNumberAsync(string verificationCode) { CheckLoginStatus(); var user = await _userRepository.GetFirstOrDefaultAsync(a => a.UserName == _userName).ConfigureAwait(false); user.ThrowIfParameterIsNull("IdentityInvalidUserName"); await _redisCacheService.ConnectAsync().ConfigureAwait(false); var cacheKey = $"pvc_{user.UserName}"; if (!(await _redisCacheService.KeyExistsAsync(cacheKey))) { throw new MilvaUserFriendlyException("ThereIsNoSavedVerificationCode"); } var verificationCodeInCache = await _redisCacheService.GetAsync(cacheKey).ConfigureAwait(false); if (verificationCode == verificationCodeInCache) { user.PhoneNumberConfirmed = true; return(await _userManager.UpdateAsync(user).ConfigureAwait(false)); } else { throw new MilvaUserFriendlyException("WrongPhoneNumberVerificationCode"); } }