public async Task <User> Authenticate(VkLoginInfo loginInfo) { var bytes = $"expire={loginInfo.Expire}mid={loginInfo.Mid}secret={loginInfo.Secret}sid={loginInfo.Sid}{vkAppConfig.SecretKey}" .ToBytes(); var md5Hash = cryptoHelper.ComputeMD5(bytes); if (md5Hash.ToHex() != loginInfo.Sig.ToUpper()) { logger.LogWarning($"Не удалось войти по VK {loginInfo.Mid}. Не совпала подпись"); throw new AuthenticationFailedException(); } var account = await accountsRepo.FirstOrDefaultAsync( a => a.Type == AuthenticationType.Vk && a.ServiceId == loginInfo.Mid); if (account == default(AuthenticationAccount)) { logger.LogWarning($"Не удалось войти по VK {loginInfo.Mid}. Нет аккаунта."); throw new AuthenticationFailedException(); } return(await usersRepo.GetByIdAsync(account.UserId)); }