Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 486a430

Browse files
committed
Corrected bug where a changed password would keep your account in limbo
1 parent 81cc508 commit 486a430

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

CodeHub.Core/ViewModels/Accounts/AccountsViewModel.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ protected override void AddAccount()
2727
protected async override void SelectAccount(IAccount account)
2828
{
2929
var githubAccount = (GitHubAccount) account;
30+
var isEnterprise = githubAccount.IsEnterprise || !string.IsNullOrEmpty(githubAccount.Password);
3031

3132
if (githubAccount.DontRemember)
3233
{
3334
//Hack for now
34-
if (githubAccount.IsEnterprise || !string.IsNullOrEmpty(githubAccount.Password))
35+
if (isEnterprise)
3536
{
3637
ShowViewModel<AddAccountViewModel>(new AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id });
3738
}
@@ -49,9 +50,17 @@ protected async override void SelectAccount(IAccount account)
4950
var client = await _loginService.LoginAccount(githubAccount);
5051
_applicationService.ActivateUser(githubAccount, client);
5152
}
53+
catch (GitHubSharp.UnauthorizedException e)
54+
{
55+
ReportError(e);
56+
if (isEnterprise)
57+
ShowViewModel<AddAccountViewModel>(new AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = githubAccount.Id });
58+
else
59+
ShowViewModel<LoginViewModel>(LoginViewModel.NavObject.CreateDontRemember(githubAccount));
60+
}
5261
catch (Exception e)
5362
{
54-
Error = e;
63+
ReportError(e);
5564
}
5665
finally
5766
{

CodeHub.Core/ViewModels/App/StartupViewModel.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ protected async override void Startup()
3333
return;
3434
}
3535

36+
var isEnterprise = account.IsEnterprise || !string.IsNullOrEmpty(account.Password);
3637
if (account.DontRemember)
3738
{
3839
ShowViewModel<Accounts.AccountsViewModel>();
3940

4041
//Hack for now
41-
if (account.IsEnterprise || !string.IsNullOrEmpty(account.Password))
42+
if (isEnterprise)
4243
{
4344
ShowViewModel<Accounts.AddAccountViewModel>(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id });
4445
}
@@ -57,9 +58,19 @@ protected async override void Startup()
5758
var client = await _loginService.LoginAccount(account);
5859
_applicationService.ActivateUser(account, client);
5960
}
61+
catch (GitHubSharp.UnauthorizedException e)
62+
{
63+
ReportError(e);
64+
ShowViewModel<Accounts.AccountsViewModel>();
65+
if (isEnterprise)
66+
ShowViewModel<Accounts.AddAccountViewModel>(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id });
67+
else
68+
ShowViewModel<Accounts.LoginViewModel>(Accounts.LoginViewModel.NavObject.CreateDontRemember(account));
69+
}
6070
catch (Exception e)
6171
{
62-
Error = e;
72+
ReportError(e);
73+
ShowViewModel<Accounts.AccountsViewModel>();
6374
}
6475
finally
6576
{

0 commit comments

Comments
 (0)