mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 14:24:32 +00:00
8ff960189e
- Update: Added "Copy Password" to Mafile context menu (if available) - Update: "Save Password" now pre-fills the current password in the "Login Again" dialog when encryption is enabled - Fix: Prevented overlapping confirmation cycles in AutoConfirmer - Fix: Added a Snackbar notification when a confirmation cycle is skipped due to a too frequent timer interval - Fix: Fixed a rare bug where the previous proxy was used instead of the current one during session refresh - Fix: Corrected "Session Permanently Expired" message showing on unrelated errors (e.g. network issues) - UI-Fix: Fixed visual glitch where proxy input appeared non-empty when switching to a mafile-specific proxy - Cleanup: Refactored and cleaned up codebase, improved styling and formatting via ReSharper
71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Media.Imaging;
|
|
using SteamLib.Core.Interfaces;
|
|
using SteamLib.Exceptions;
|
|
|
|
namespace NebulaAuth.View.Dialogs;
|
|
|
|
/// <summary>
|
|
/// Логика взаимодействия для WaitLoginDialog.xaml
|
|
/// </summary>
|
|
public partial class WaitLoginDialog : ICaptchaResolver
|
|
{
|
|
private TaskCompletionSource<string> _tcs = new();
|
|
|
|
public WaitLoginDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public async Task<string> Resolve(Uri imageUrl, HttpClient client)
|
|
{
|
|
CaptchaGrid.Visibility = Visibility.Visible;
|
|
var stream = await client.GetStreamAsync(imageUrl);
|
|
return await Application.Current.Dispatcher.Invoke(async () =>
|
|
{
|
|
var image = await LoadImage(stream);
|
|
CaptchaImage.Source = image;
|
|
try
|
|
{
|
|
return await _tcs.Task;
|
|
}
|
|
catch (TaskCanceledException)
|
|
{
|
|
throw new LoginException(LoginError.CaptchaRequired);
|
|
}
|
|
});
|
|
}
|
|
|
|
private async Task<BitmapImage> LoadImage(Stream stream)
|
|
{
|
|
using var ms = new MemoryStream();
|
|
await stream.CopyToAsync(ms);
|
|
ms.Position = 0;
|
|
|
|
var image = new BitmapImage();
|
|
|
|
image.BeginInit();
|
|
image.CacheOption = BitmapCacheOption.OnLoad;
|
|
image.StreamSource = ms;
|
|
image.EndInit();
|
|
await stream.DisposeAsync();
|
|
return image;
|
|
}
|
|
|
|
private void CancelButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
_tcs.SetCanceled();
|
|
}
|
|
|
|
private void SendCaptchaBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(CaptchaTB.Text)) return;
|
|
var oldTcs = _tcs;
|
|
_tcs = new TaskCompletionSource<string>();
|
|
oldTcs.SetResult(CaptchaTB.Text);
|
|
}
|
|
} |