@@ -235,6 +235,7 @@ function allIncluded(outputTarget = 'email') {
235
235
cacheKey : githubCache . cacheKey ,
236
236
timestamp : githubCache . timestamp ,
237
237
subject : subject ,
238
+ usedToken : ! ! githubToken ,
238
239
}
239
240
log ( `Saving data to storage:` , {
240
241
cacheKey : githubCache . cacheKey ,
@@ -283,6 +284,7 @@ function allIncluded(outputTarget = 'email') {
283
284
githubCache . cacheKey = cache . cacheKey ;
284
285
githubCache . timestamp = cache . timestamp ;
285
286
githubCache . subject = cache . subject ;
287
+ githubCache . usedToken = cache . usedToken || false ;
286
288
287
289
if ( cache . subject && scrumSubject ) {
288
290
scrumSubject . value = cache . subject ;
@@ -323,11 +325,18 @@ function allIncluded(outputTarget = 'email') {
323
325
const now = Date . now ( ) ;
324
326
const isCacheFresh = ( now - githubCache . timestamp ) < githubCache . ttl ;
325
327
const isCacheKeyMatch = githubCache . cacheKey === cacheKey ;
328
+ const needsToken = ! ! githubToken ;
329
+ const cacheUsedToken = ! ! githubCache . usedToken ;
326
330
327
331
if ( githubCache . data && isCacheFresh & isCacheKeyMatch ) {
328
- log ( 'Using cached data - cache is fresh and key matches' ) ;
329
- processGithubData ( githubCache . data ) ;
330
- return Promise . resolve ( ) ;
332
+ if ( needsToken & ! cacheUsedToken ) {
333
+ log ( 'Cache was fetched without token, but user now has a token. Invalidating cache.' ) ;
334
+ githubCache . data = null ;
335
+ } else {
336
+ log ( 'Using cached data - cache is fresh and key matches' ) ;
337
+ processGithubData ( githubCache . data ) ;
338
+ return Promise . resolve ( ) ;
339
+ }
331
340
}
332
341
// if cache key does not match our cache is stale, fetch new data
333
342
if ( ! isCacheKeyMatch ) {
0 commit comments