This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Commit e57463b
committed
Dedupe code in ApiClient. Also, cache user data and avoid using the keychain username
The system keychain may have a valid token with an invalid username
because every git client fills out that information slightly different
and the username is not relevant for accessing the API
(only the token is needed). If we encounter a mismatch, don't throw
immediately (the token might be perfectly valid), but always doublecheck
the github user to make sure the username of the connection matches
the user that the token is associated with.
Cache the GitHubUser object in the Connection list (non serialized) so that
if we fill out once and all the information matches, we can reuse it and
avoid pinging the API every time. If another git client tramples all over
our keychain, it's highly likely that they'll also not fill out the username
information anyway, and we always grab the user from GitHub if that happens
so we should be relatively safe trusting the cached GitHubUser object
(it'll get thrown away whenever Unity reloads so it's also likely that we'll
keep refreshing it anyways)
In the process of this, cleaned up some duplicated and uneeded code that could
lead to issues later on.1 parent 60da5ec commit e57463b
File tree
8 files changed
+51
-65
lines changed- src
- GitHub.Api
- Application
- Authentication
- UnityExtension/Assets/Editor/GitHub.Unity
- Services
- UI
- tests/UnitTests/Authentication
8 files changed
+51
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 13 | | |
25 | 14 | | |
26 | 15 | | |
| |||
81 | 70 | | |
82 | 71 | | |
83 | 72 | | |
84 | | - | |
| 73 | + | |
85 | 74 | | |
86 | 75 | | |
87 | 76 | | |
88 | 77 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 78 | + | |
| 79 | + | |
93 | 80 | | |
94 | 81 | | |
95 | 82 | | |
96 | 83 | | |
97 | 84 | | |
98 | 85 | | |
99 | 86 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | 87 | | |
113 | 88 | | |
114 | 89 | | |
| |||
205 | 180 | | |
206 | 181 | | |
207 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
208 | 202 | | |
209 | 203 | | |
210 | 204 | | |
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
| 208 | + | |
| 209 | + | |
218 | 210 | | |
219 | 211 | | |
220 | 212 | | |
| |||
240 | 232 | | |
241 | 233 | | |
242 | 234 | | |
243 | | - | |
| 235 | + | |
244 | 236 | | |
245 | 237 | | |
246 | 238 | | |
| |||
273 | 265 | | |
274 | 266 | | |
275 | 267 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 268 | + | |
| 269 | + | |
280 | 270 | | |
281 | 271 | | |
282 | | - | |
| 272 | + | |
283 | 273 | | |
284 | 274 | | |
285 | 275 | | |
| |||
315 | 305 | | |
316 | 306 | | |
317 | 307 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
327 | 311 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
333 | 317 | | |
334 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
335 | 321 | | |
336 | 322 | | |
337 | | - | |
338 | | - | |
| 323 | + | |
339 | 324 | | |
340 | 325 | | |
341 | 326 | | |
342 | 327 | | |
343 | 328 | | |
344 | 329 | | |
345 | 330 | | |
346 | | - | |
| 331 | + | |
347 | 332 | | |
348 | 333 | | |
349 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
| 500 | + | |
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
0 commit comments