Skip to content

fix: handle invalid oidc session date after jwt is expired #1939

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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

abdimo101
Copy link
Contributor

@abdimo101 abdimo101 commented Jul 16, 2025

Description

Fix authentication issues and infinite loading after logging in with OIDC and returning with an expired JWT.

Motivation

When logging in with OIDC and returning to the site after the JWT expires, the site would attempt to fetch user data and dataset table get stuck in an infinite loading state. This happened because the invalid created property in OIDC session caused the isTokenExpired check to fail.

Fixes:

  • Validates the created property to prevent unnecessary API calls and ensures authentication cookies are cleared when the JWT has expired.
  • Reloads the page after clearing authentication so the dataset table does not remain in an infinite loading state.

Changes:

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Handle invalid OIDC session dates to fix authentication loops after expired JWTs and overhaul the dataset filter component to introduce a full-featured scientific conditions UI with corresponding test coverage

Bug Fixes:

  • Validate the OIDC session creation date to null if invalid to prevent token expiry checks from failing
  • Reload the page after clearing authentication when a JWT is expired to avoid infinite loading

Enhancements:

  • Add expansion-panel based UI for scientific metadata conditions with support for enabling, disabling, editing, and removing conditions
  • Auto-apply saved or pre-configured scientific conditions on component initialization
  • Update dataset filter settings UI layout and styling including new buttons and responsive width configuration

Build:

  • Import MatExpansionModule and related Angular Material modules for the new conditions UI

Tests:

  • Update unit tests to reflect dialog width and dispatch count changes
  • Extend Cypress E2E tests to cover adding, toggling, removing scientific conditions and pre-configured filters/conditions scenarios

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @abdimo101 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -179,6 +220,229 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy {
this.store.dispatch(fetchFacetCountsAction());
}

trackByCondition(index: number, conditionConfig: ConditionConfig): string {
const condition = conditionConfig.condition;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const condition = conditionConfig.condition;
const {condition} = conditionConfig;


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

this.asyncPipe.transform(this.conditionConfigs$) || [];
const updatedConditions = [...currentConditions];
updatedConditions[index] = { ...updatedConditions[index], enabled };
const condition = updatedConditions[index].condition;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const condition = updatedConditions[index].condition;
const {condition} = updatedConditions[index];


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

@@ -39,7 +39,8 @@ export class AuthService {
this.token.id = this.load("id");
this.token.user = JSON.parse(this.load("user") || null);
this.token.userId = this.load("userId");
this.token.created = new Date(this.load("created"));
const date = new Date(this.load("created"));
this.token.created = !isNaN(date.getTime()) ? date : null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Invert ternary operator to remove negation (invert-ternary)

Suggested change
this.token.created = !isNaN(date.getTime()) ? date : null;
this.token.created = isNaN(date.getTime()) ? null : date;


ExplanationNegated conditions are more difficult to read than positive ones, so it is best
to avoid them where we can. By inverting the ternary condition and swapping the
expressions we can simplify the code.

@abdimo101 abdimo101 requested a review from Junjiequan July 17, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant