This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Read scopes at the same time as User. #331
Merged
shana
merged 6 commits into
grokys/feature/gist-support
from
grokys/scope-read-optimize
May 27, 2016
Merged
Read scopes at the same time as User. #331
shana
merged 6 commits into
grokys/feature/gist-support
from
grokys/scope-read-optimize
May 27, 2016
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, if an exception occurred while logging in to an account that has previously been logged in, then an AccountCacheItem was read from the cache and that was used. This meant we couldn't check the response's scopes for gist support.
This way we only need to make 1 request at login.
| { | ||
| return hostCache.GetAndRefreshObject("user", | ||
| () => apiClient.GetUser().Select(AccountCacheItem.Create), TimeSpan.FromMinutes(5), TimeSpan.FromDays(7)) | ||
| () => apiClient.GetUser().Select(x => new AccountCacheItem(x.User)), TimeSpan.FromMinutes(5), TimeSpan.FromDays(7)) |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep with the convention of using Create methods on these calls, add an overload to AccountCacheItem.Create that takes a UserAndScopes object instead.
Contributor
|
I debugged this some and yeah, logic looks about right. The whole login thing should definitely be cleaned up, it's waaay too complicated, but no point doing that here. |
src/GitHub.App/Api/ApiClient.cs
Outdated
| static readonly Logger log = LogManager.GetCurrentClassLogger(); | ||
| static readonly Uri userEndpoint = new Uri("user", UriKind.Relative); | ||
|
|
||
| const string ProductName = Info.ApplicationInfo.ApplicationDescription; |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contributor
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Also remove what looked like incorrect logic in that if login failed, the login was read from cache.