Skip to content

Commit

Permalink
Login flow improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Top-Cat committed Dec 27, 2015
1 parent 6f2ef42 commit 468b2d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Login.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<StackPanel x:Name="LoginGrid" Grid.Row="1" Margin="12,17,12,28">
<!--UserName-->
<TextBlock x:Name="UserNameLabel" Text="Steam username" Foreground="White" FontSize="20"/>
<TextBox BorderBrush="LightGray" Name="UserName" IsTextPredictionEnabled="False" IsSpellCheckEnabled="False" />
<TextBox BorderBrush="LightGray" Name="UserName" IsTextPredictionEnabled="False" IsSpellCheckEnabled="False" />

<!--Password-->
<TextBlock x:Name="PasswordLabel" Foreground="White" Text="Password" FontSize="20"/>
Expand All @@ -52,7 +52,7 @@
<!--Login Button-->
<Button Content="Sign In" Foreground="White" BorderBrush="LightGray" Name="LoginBtn" Click="LoginBtn_Click" />
<TextBlock x:Name="ErrorLabel" Text="Invalid Credentials" Foreground="Red" Margin="0,-40,0,0" FontSize="20" HorizontalAlignment="Right" Visibility="Collapsed"/>
<ProgressBar x:Name="Progress" Height="40" VerticalAlignment="Stretch" IsIndeterminate="True" IsEnabled="False" Visibility="Collapsed"/>
<ProgressBar x:Name="Progress" Height="40" VerticalAlignment="Stretch" IsIndeterminate="True" Visibility="Collapsed"/>

</StackPanel>

Expand Down
17 changes: 11 additions & 6 deletions Login.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
ResetView();
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
HardwareButtons.BackPressed -= BackPressed;
}

private void BackPressed(object s, BackPressedEventArgs args)
{
if (LoginGrid.Visibility == Visibility.Collapsed)
Expand All @@ -65,7 +70,6 @@ private void LoginBtn_Click(object sender, RoutedEventArgs e)
{
UserName.IsTabStop = PassWord.IsTabStop = false;
ErrorLabel.Visibility = LoginBtn.Visibility = Visibility.Collapsed;
Progress.IsEnabled = true;
Progress.Visibility = Visibility.Visible;
UserName.IsTabStop = PassWord.IsTabStop = true;

Expand Down Expand Up @@ -107,20 +111,20 @@ private void ProcessLoginResponse(LoginResult response)
}
else if (response == LoginResult.Need2FA)
{
Progress.IsEnabled = true;
SteamGuardAccount account = Storage.SGAFromStore(UserName.Text);
if ((login.TwoFactorCode == null || login.TwoFactorCode.Length == 0) && account != null)
{
LoginGrid.Visibility = Visibility.Visible;
Progress.Visibility = LoginGrid.Visibility = Visibility.Visible;
LoginBtn.Visibility = Visibility.Collapsed;

account.GenerateSteamGuardCode(async code =>
{
if (code == null || code.Length == 0)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
ErrorLabel.Text = "Need 2FA";
TwoFactorCode.Text = "";
TwoFactorGrid.Visibility = ErrorLabel.Visibility = Visibility.Visible;
login.TwoFactorCode = " ";
ProcessLoginResponse(LoginResult.Need2FA);
});
return;
}
Expand Down Expand Up @@ -158,6 +162,7 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
else if (response == LoginResult.LoginOkay)
{
Storage.PushStore(login.Session);
LoginBtn.Visibility = Visibility.Collapsed;
Frame.Navigate(typeof(MainPage), login.Session);
}
}
Expand Down

0 comments on commit 468b2d6

Please sign in to comment.