Added more UI to the Credentials login form and catch exception

This commit is contained in:
erri120 2020-04-28 14:11:12 +02:00
parent 3548e42a64
commit 670efbdb10
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 23 additions and 10 deletions

View File

@ -4,6 +4,7 @@ using System.Reactive.Linq;
using System.Security;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.Lib.Downloaders;
@ -34,14 +35,22 @@ namespace Wabbajack
public void Login(SecureString password)
{
if (password == null || password.Length == 0)
try
{
ReturnMessage = new LoginReturnMessage("You need to input a password!", true);
return;
}
if (password == null || password.Length == 0)
{
ReturnMessage = new LoginReturnMessage("You need to input a password!", true);
return;
}
ReturnMessage = _downloader.LoginWithCredentials(Username, password);
password.Clear();
ReturnMessage = _downloader.LoginWithCredentials(Username, password);
password.Clear();
}
catch (Exception e)
{
Utils.Error(e, "Exception while trying to login");
ReturnMessage = new LoginReturnMessage($"Unhandled exception: {e.Message}", true);
}
}
private static bool IsValidAddress(string s)

View File

@ -17,18 +17,22 @@
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<TextBox FontSize="20" x:Name="Username" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
<PasswordBox Margin="0 16 0 -8" FontSize="20" x:Name="Password" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"/>
<TextBlock FontSize="20" Grid.Row="0" Grid.Column="0" Margin="0 16 8 0">Email:</TextBlock>
<TextBox FontSize="20" x:Name="Username" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"/>
<Button Margin="8 8 0 0" x:Name="LoginButton" Grid.Row="2" Grid.Column="2" Click="LoginButton_OnClick">
<TextBlock FontSize="20" Grid.Row="1" Grid.Column="0" Margin="0 16 8 0">Password:</TextBlock>
<PasswordBox Margin="0 16 0 -8" FontSize="20" x:Name="Password" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<Button Margin="8 8 0 0" x:Name="LoginButton" Grid.Row="2" Grid.Column="3" Click="LoginButton_OnClick">
<TextBlock FontSize="14">Login</TextBlock>
</Button>
<TextBox x:Name="Message" FontSize="20" Margin="0 16 0 0" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3"/>
<TextBlock x:Name="Message" FontSize="20" Margin="0 16 0 0" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3"/>
</Grid>
</rxui:ReactiveUserControl>