Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
1c238425
Commit
1c238425
authored
Sep 16, 2020
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Re-fetch info.json documents after logging out
parent
ae4c0baa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
__tests__/src/sagas/auth.test.js
+16
-0
16 additions, 0 deletions
__tests__/src/sagas/auth.test.js
__tests__/src/sagas/iiif.test.js
+2
-21
2 additions, 21 deletions
__tests__/src/sagas/iiif.test.js
src/state/sagas/auth.js
+11
-1
11 additions, 1 deletion
src/state/sagas/auth.js
with
29 additions
and
22 deletions
__tests__/src/sagas/auth.test.js
+
16
−
0
View file @
1c238425
...
...
@@ -5,6 +5,7 @@ import serviceFixture from '../../fixtures/version-2/canvasService.json';
import
ActionTypes
from
'
../../../src/state/actions/action-types
'
;
import
{
refetchInfoResponses
,
refetchInfoResponsesOnLogout
,
}
from
'
../../../src/state/sagas/auth
'
;
import
{
fetchInfoResponse
,
...
...
@@ -17,6 +18,21 @@ import {
}
from
'
../../../src/state/selectors
'
;
describe
(
'
IIIF Authentication sagas
'
,
()
=>
{
describe
(
'
refetchInfoResponsesOnLogout
'
,
()
=>
{
it
(
'
delays and then refetches info responses
'
,
()
=>
{
const
tokenServiceId
=
'
whatever
'
;
/** stub out delay... ugh. */
const
provideDelay
=
({
fn
},
next
)
=>
((
fn
.
name
===
'
delayP
'
)
?
null
:
next
());
return
expectSaga
(
refetchInfoResponsesOnLogout
,
{
tokenServiceId
})
.
provide
([
{
call
:
provideDelay
},
[
call
(
refetchInfoResponses
,
{
serviceId
:
tokenServiceId
}),
{}],
])
.
call
(
refetchInfoResponses
,
{
serviceId
:
tokenServiceId
})
.
run
();
});
});
describe
(
'
refetchInfoResponses
'
,
()
=>
{
it
(
'
discards info responses that could hvae used the new access token
'
,
()
=>
{
const
serviceId
=
'
https://authentication.example.org/token
'
;
...
...
This diff is collapsed.
Click to expand it.
__tests__/src/sagas/iiif.test.js
+
2
−
21
View file @
1c238425
import
{
call
,
select
}
from
'
redux-saga/effects
'
;
import
{
expectSaga
,
testSaga
}
from
'
redux-saga-test-plan
'
;
import
{
select
}
from
'
redux-saga/effects
'
;
import
{
expectSaga
}
from
'
redux-saga-test-plan
'
;
import
{
fetchAnnotation
,
fetchManifest
,
fetchSearchResponse
,
fetchInfoResponse
,
refetchInfoResponses
,
fetchResourceManifest
,
}
from
'
../../../src/state/sagas/iiif
'
;
import
{
...
...
@@ -217,24 +216,6 @@ describe('IIIF sagas', () => {
});
});
describe
(
'
refetchInfoResponses
'
,
()
=>
{
it
(
'
refetches info responses when a new access token is available
'
,
()
=>
{
const
serviceId
=
'
serviceId
'
;
const
tokenService
=
{
id
:
serviceId
,
infoIds
:
[
'
x
'
,
'
y
'
]
};
testSaga
(
refetchInfoResponses
,
{
serviceId
})
.
next
()
.
select
(
getAccessTokens
)
.
next
({
serviceId
:
tokenService
})
.
all
([
call
(
fetchInfoResponse
,
{
infoId
:
'
x
'
,
tokenService
}),
call
(
fetchInfoResponse
,
{
infoId
:
'
y
'
,
tokenService
}),
])
.
next
()
.
put
({
serviceId
,
type
:
'
mirador/CLEAR_ACCESS_TOKEN_QUEUE
'
});
});
});
describe
(
'
fetchSearchResponse
'
,
()
=>
{
it
(
'
fetches a IIIF search
'
,
()
=>
{
fetch
.
mockResponseOnce
(
JSON
.
stringify
({
data
:
'
12345
'
}));
...
...
This diff is collapsed.
Click to expand it.
src/state/sagas/auth.js
+
11
−
1
View file @
1c238425
import
{
all
,
call
,
put
,
select
,
takeEvery
,
all
,
call
,
put
,
select
,
takeEvery
,
delay
,
}
from
'
redux-saga/effects
'
;
import
{
Utils
}
from
'
manifesto.js/dist-esmodule/Utils
'
;
import
flatten
from
'
lodash/flatten
'
;
...
...
@@ -12,6 +12,15 @@ import {
}
from
'
../selectors
'
;
import
{
fetchInfoResponse
}
from
'
./iiif
'
;
/** */
export
function
*
refetchInfoResponsesOnLogout
({
tokenServiceId
})
{
// delay logout actions to give the cookie service a chance to invalidate our cookies
// before we reinitialize openseadragon and rerequest images.
yield
delay
(
2000
);
yield
call
(
refetchInfoResponses
,
{
serviceId
:
tokenServiceId
});
}
/**
* Figure out what info responses could have used the access token service and:
* - refetch, if they are currently visible
...
...
@@ -55,5 +64,6 @@ export function* refetchInfoResponses({ serviceId }) {
export
default
function
*
authSaga
()
{
yield
all
([
takeEvery
(
ActionTypes
.
RECEIVE_ACCESS_TOKEN
,
refetchInfoResponses
),
takeEvery
(
ActionTypes
.
RESET_AUTHENTICATION_STATE
,
refetchInfoResponsesOnLogout
),
]);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment