Allow testing of credentials from UI (fixes #171)

This commit is contained in:
Matt Nadareski
2020-01-26 22:59:03 -08:00
parent f7f464920b
commit 7073d4e298
2 changed files with 19 additions and 3 deletions

View File

@@ -148,6 +148,7 @@
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1.2*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
@@ -158,7 +159,9 @@
<TextBox x:Name="RedumpUsernameTextBox" Grid.Row="0" Grid.Column="1" Height="22" HorizontalAlignment="Stretch" />
<Label Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Password" />
<TextBox x:Name="RedumpPasswordTextBox" Grid.Row="0" Grid.Column="3" Height="22" HorizontalAlignment="Stretch" />
<PasswordBox x:Name="RedumpPasswordBox" Grid.Row="0" Grid.Column="3" Height="22" HorizontalAlignment="Stretch" PasswordChar="*" />
<Button x:Name="RedumpLoginTestButton" Grid.Row="0" Grid.Column="5" Height="22" Width="80" Content="Test Login" Click="OnRedumpTestClick" />
</Grid>
</GroupBox>

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Windows;
using System.Windows.Forms;
using DICUI.Web;
using Button = System.Windows.Controls.Button;
using TextBox = System.Windows.Controls.TextBox;
@@ -105,7 +106,7 @@ namespace DICUI.Windows
DumpSpeedBDSlider.Value = _options.PreferredDumpSpeedBD;
RedumpUsernameTextBox.Text = _options.Username;
RedumpPasswordTextBox.Text = _options.Password;
RedumpPasswordBox.Password = _options.Password;
}
#region Event Handlers
@@ -119,7 +120,7 @@ namespace DICUI.Windows
_options.PreferredDumpSpeedBD = Convert.ToInt32(DumpSpeedBDSlider.Value);
_options.Username = RedumpUsernameTextBox.Text;
_options.Password = RedumpPasswordTextBox.Text;
_options.Password = RedumpPasswordBox.Password;
_options.Save();
Hide();
@@ -133,6 +134,18 @@ namespace DICUI.Windows
Hide();
}
private void OnRedumpTestClick(object sender, EventArgs e)
{
using (CookieAwareWebClient wc = new CookieAwareWebClient())
{
RedumpAccess access = new RedumpAccess();
if (access.RedumpLogin(wc, RedumpUsernameTextBox.Text, RedumpPasswordBox.Password))
System.Windows.MessageBox.Show("Redump login credentials accepted!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
else
System.Windows.MessageBox.Show("Redump login credentials denied!", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion
}
}