dspace-angular icon indicating copy to clipboard operation
dspace-angular copied to clipboard

[DURACOM-496] fix redirect for item page resolver

Open FrankGameDev opened this issue 5 months ago • 0 comments

Porting of [CST-24936]

Fixes #5853

References

  • https://4science.atlassian.net/browse/DURACOM-496
  • https://github.com/DSpace/dspace-angular/issues/5853

Description

Fixes the issue https://github.com/DSpace/dspace-angular/issues/5853

List of changes in this PR:

  1. Fixed redirect URL capture in authorized.operators.ts: Changed the redirectOn4xx operator to use router.getCurrentNavigation()?.extractedUrl?.toString() instead of router.url when capturing the redirect URL for unauthenticated users hitting 401/403 errors. This ensures the actual destination URL is captured during resolvers, rather than the stale previous URL.
  2. Added getCurrentNavigation to router spy in tests: Updated the test spy in operators.spec.ts to include the getCurrentNavigation method so existing tests continue to pass.

How to test it

  1. Log in as administrator
  2. Navigate to a restricted item
  3. Copy the item URL and open it in a new browser tab
  4. Expected (after fix): User is redirected to login page, and after login, redirected back to the restricted item

FrankGameDev avatar Jun 19 '26 09:06 FrankGameDev