Honor remote logout during session refresh
This commit is contained in:
@@ -1855,6 +1855,41 @@ describe('session', () => {
|
||||
expect(rebased.accounts).toEqual([fresh])
|
||||
})
|
||||
|
||||
it('honors a remote logout over a concurrent local refresh', () => {
|
||||
const stale = makeAccount('https://alice.com', {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
handle: 'alice.test',
|
||||
accessJwt: 'alice-access-jwt-1',
|
||||
refreshJwt: 'alice-refresh-jwt-1',
|
||||
})
|
||||
const refreshed = {
|
||||
...stale,
|
||||
accessJwt: 'alice-access-jwt-2',
|
||||
refreshJwt: 'alice-refresh-jwt-2',
|
||||
}
|
||||
const loggedOut = {
|
||||
...stale,
|
||||
accessJwt: undefined,
|
||||
refreshJwt: undefined,
|
||||
}
|
||||
|
||||
const rebased = rebasePersistedSession(
|
||||
snapshot([loggedOut]),
|
||||
snapshot([refreshed], 'alice-did'),
|
||||
{
|
||||
type: 'received-session-event',
|
||||
bundle: makeBundle('https://alice.com'),
|
||||
accountDid: 'alice-did',
|
||||
refreshedAccount: refreshed,
|
||||
sessionEvent: 'update',
|
||||
},
|
||||
)
|
||||
|
||||
expect(rebased.accounts).toEqual([loggedOut])
|
||||
expect(rebased.currentAccount).toBeUndefined()
|
||||
})
|
||||
|
||||
it('preserves a concurrent newer generation instead of clearing it on expiry', () => {
|
||||
const dying = makeAccount('https://alice.com', {
|
||||
active: true,
|
||||
|
||||
@@ -210,10 +210,10 @@ function selectCurrentDid({
|
||||
return desiredCurrentDid
|
||||
case 'received-session-event':
|
||||
if (
|
||||
action.sessionEvent === 'expired' &&
|
||||
action.accountDid !== undefined &&
|
||||
preservedNewerTokenDids.has(action.accountDid)
|
||||
) {
|
||||
/* The latest tokens also own account selection after a conflict. */
|
||||
return latestCurrentDid
|
||||
}
|
||||
return action.sessionEvent === 'expired'
|
||||
|
||||
Reference in New Issue
Block a user