Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOR-912 spread session, _self data when resuming session #1568

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Use the `users-keycloak/_self` endpoint conditionally when the `users-keycloak` interface is present; otherwise, use `bl-users/_self` within `useUserTenantPermissions`. Refs STCOR-905.
* Don't override initial discovery and okapi data in test mocks. Refs STCOR-913.
* `<Logout>` must consume `QueryClient` in order to supply it to `loginServices::logout()`. Refs STCOR-907.
* On resuming session, spread session and `_self` together to preserve session values. Refs STCOR-912.

## [10.2.0](https://github.com/folio-org/stripes-core/tree/v10.2.0) (2024-10-11)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.1.1...v10.2.0)
Expand Down
5 changes: 4 additions & 1 deletion src/loginServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,10 @@ export function validateUser(okapiUrl, store, tenant, session) {
// data isn't provided by _self.
store.dispatch(setSessionData({
isAuthenticated: true,
user,
// spread data from the previous session (which may include session-specific
// values such as the current service point), and the restructured user object
// (which includes permissions in a lookup-friendly way)
user: { ...session.user, ...user },
perms,
tenant: sessionTenant,
token,
Expand Down
8 changes: 6 additions & 2 deletions src/loginServices.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ describe('validateUser', () => {
};

const session = {
user: { id: 'id', username: 'username' },
user: {
id: 'id',
username: 'username',
storageOnlyValue: 'is still persisted',
},
perms: { foo: true },
tenant: sessionTenant,
token: 'token',
Expand All @@ -361,7 +365,7 @@ describe('validateUser', () => {
await validateUser('url', store, tenant, session);

const updatedSession = {
user: data.user,
user: { ...session.user, ...data.user },
isAuthenticated: true,
perms: { ask: true, tell: true },
tenant: session.tenant,
Expand Down
Loading