8000 Remove duplicate credential classes. by grokys · Pull Request #1200 · github/VisualStudio · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Remove duplicate credential classes. #1200

Merged
merged 10 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into fixes/1176-duplicate-login-classes
 Conflicts:
	src/GitHub.App/Models/RepositoryHost.cs
	src/UnitTests/GitHub.App/Models/RepositoryHostTests.cs
  • Loading branch information
grokys committed Aug 30, 2017
commit 7b4080ffa79889b7c8810ce5673bf71c04206b1f
47 changes: 0 additions & 47 deletions src/GitHub.App/Models/RepositoryHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,53 +142,6 @@ public IObservable<Unit> LogOut()
});
}

static IObservable<AuthenticationResult> GetAuthenticationResultForUser(UserAndScopes account)
{
return Observable.Return(account == null ? AuthenticationResult.CredentialFailure
: account == unverifiedUser
? AuthenticationResult.VerificationFailure
: AuthenticationResult.Success);
}

IObservable<AuthenticationResult> LoginWithApiUser(UserAndScopes userAndScopes)
{
return GetAuthenticationResultForUser(userAndScopes)
.SelectMany(result =>
{
if (result.IsSuccess())
{
var accountCacheItem = new AccountCacheItem(userAndScopes.User);
usage.IncrementLoginCount().Forget();
return ModelService.InsertUser(accountCacheItem).Select(_ => result);
}

if (result == AuthenticationResult.VerificationFailure)
{
return keychain.Delete(Address).ToObservable().Select(_ => result);
}
return Observable.Return(result);
})
.ObserveOn(RxApp.MainThreadScheduler)
.Do(result =>
{
if (result.IsSuccess())
{
SupportsGist = userAndScopes.Scopes?.Contains("gist") ?? true;
IsLoggedIn = true;
}

log.Info("Log in from cache for login '{0}' to host '{1}' {2}",
userAndScopes?.User?.Login ?? "(null)",
hostAddress.ApiUri,
result.IsSuccess() ? "SUCCEEDED" : "FAILED");
});
}

IObservable<UserAndScopes> GetUserFromApi()
{
return Observable.Defer(() => ApiClient.GetUser());
}

protected virtual void Dispose(bool disposing)
{}

Expand Down
4 changes: 2 additions & 2 deletions src/UnitTests/GitHub.App/Models/RepositoryHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task LogsTheUserInSuccessfullyAndCachesRelevantInfo()
apiClient.GetOrCreateApplicationAuthenticationCode(
Args.TwoFactorChallengCallback, Args.String, Args.Boolean)
.Returns(Observable.Return(new ApplicationAuthorization("S3CR3TS")));
apiClient.GetUser().Returns(Observable.Return(CreateOctokitUser("baymax")));
apiClient.GetUser().Returns(Observable.Return(CreateUserAndScopes("baymax")));
var hostCache = new InMemoryBlobCache();
var modelService = new ModelService(apiClient, hostCache, Substitute.For<IAvatarProvider>());
var loginManager = Substitute.For<ILoginManager>();
Expand All @@ -51,7 +51,7 @@ public async Task IncrementsLoginCount()
apiClient.GetOrCreateApplicationAuthenticationCode(
Args.TwoFactorChallengCallback, Args.String, Args.Boolean)
.Returns(Observable.Return(new ApplicationAuthorization("S3CR3TS")));
apiClient.GetUser().Returns(Observable.Return(CreateOctokitUser("baymax")));
apiClient.GetUser().Returns(Observable.Return(CreateUserAndScopes("baymax")));
var hostCache = new InMemoryBlobCache();
var modelService = Substitute.For<IModelService>();
var loginManager = Substitute.For<ILoginManager>();
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0