Skip to content

Commit

Permalink
Automatically refresh session if necessary when polling for trade con…
Browse files Browse the repository at this point in the history
…firmations in background
  • Loading branch information
geel9 committed Feb 19, 2016
1 parent cddff38 commit c1b5fdc
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Steam Desktop Authenticator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void MainForm_Shown(object sender, EventArgs e)
if (manifest.Encrypted)
{
passKey = manifest.PromptForPassKey();
if(passKey == null)
if (passKey == null)
{
Application.Exit();
}
Expand Down Expand Up @@ -307,11 +307,11 @@ private void menuDeactivateAuthenticator_Click(object sender, EventArgs e)
private async void menuRefreshSession_Click(object sender, EventArgs e)
{
bool status = await currentAccount.RefreshSessionAsync();
if(status == true)
if (status == true)
{
MessageBox.Show("Your session has been refreshed.", "Session refresh", MessageBoxButtons.OK, MessageBoxIcon.Information);
manifest.SaveAccount(currentAccount, manifest.Encrypted, passKey);
}
}
else
{
MessageBox.Show("Failed to refresh your session.\nTry again soon.", "Session refresh", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down Expand Up @@ -419,8 +419,17 @@ private async void timerTradesPopup_Tick(object sender, EventArgs e)

foreach (var item in accs)
{
Confirmation[] tmp = await currentAccount.FetchConfirmationsAsync();
confs.AddRange(tmp);
try
{
Confirmation[] tmp = currentAccount.FetchConfirmations();
confs.AddRange(tmp);
}
catch (SteamGuardAccount.WGTokenInvalidException)
{
lblStatus.Text = "Refreshing session";
currentAccount.RefreshSession(); //Don't save it to the HDD, of course. We'd need their encryption passkey again.
lblStatus.Text = "";
}
}

lblStatus.Text = "";
Expand Down Expand Up @@ -490,7 +499,7 @@ private async Task UpdateCurrentSession()
{
await UpdateSession(currentAccount);
}

private async Task UpdateSession(SteamGuardAccount account)
{
if (account == null) return;
Expand Down

0 comments on commit c1b5fdc

Please sign in to comment.