dspace-angular
dspace-angular copied to clipboard
[DURACOM-496] fix redirect for item page resolver
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:
- 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.
- 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
- Log in as administrator
- Navigate to a restricted item
- Copy the item URL and open it in a new browser tab
- Expected (after fix): User is redirected to login page, and after login, redirected back to the restricted item