Skip to content

Commit

Permalink
Avoid navigation after token renewal #761
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Dec 17, 2024
1 parent b80980c commit 9798d02
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@lit-app/state": "1.0.0",
"@lit/localize": "0.12.2",
"dompurify": "3.2.3",
"fast-deep-equal": "^3.1.3",
"lit": "3.2.1"
},
"devDependencies": {
Expand Down
11 changes: 10 additions & 1 deletion src/state/portal-state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { State, property, query } from "@lit-app/state";
import equal from "fast-deep-equal/es6";
import {
App,
Navigation,
Expand Down Expand Up @@ -206,7 +207,8 @@ class PortalState extends State {
const { instanceId } = tokenState;
if (!instanceId) return;

this.navigation = filterAllowed(
const oldNavigation = this.navigation;
const newNavigation = filterAllowed(
settings.navigation,
instanceId,

Expand All @@ -216,6 +218,13 @@ class PortalState extends State {
tokenState.accessTokenPayload?.substitutionRoles ||
this.rolesAndPermissions,
);

// The navigation is updated every time the access token is renewed, so
// check if it has actually changed, to not cause an unwanten navigation to
// the item's default appPath.
if (!equal(oldNavigation, newNavigation)) {
this.navigation = newNavigation;
}
}

private updateNavigationItemAndGroup(
Expand Down

0 comments on commit 9798d02

Please sign in to comment.