NIFI-15393 Fix login redirect to preserve original URL#10698
NIFI-15393 Fix login redirect to preserve original URL#10698naman-shukla-ksolves wants to merge 2 commits intoapache:mainfrom
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this improvement @naman-shukla-ksolves.
From a procedural perspective, please sign all Git commits and force-push to the branch for verification.
Regarding the substantive change, I will defer to others with more perspective on the frontend, but direct reference to sessionStorage seems questionable. At minimum, having a shared service abstraction seems safer than relying on decoupled references to a common item key.
4bb39bd to
c989e3b
Compare
|
@pvillard31 Thank you for the feedback. I've addressed both points:
Please review when you have a chance. |
c989e3b to
c81552f
Compare
… before redirecting to the login page, causing users to lose their intended destination after successful authentication
c81552f to
31b39e8
Compare
|
Thanks for the mention @exceptionfactory! I'll have a look. |
mcgilman
left a comment
There was a problem hiding this comment.
Thanks for the PR @naman-shukla-ksolves! I've noted a few things below.
| if (errorResponse.status === 401) { | ||
| const currentUrl = router.url; | ||
| if (currentUrl && currentUrl !== '/login') { | ||
| storageService.setReturnUrl(currentUrl); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't think this change is needed. The auth interceptor will handle the 401 response when the user is not logged in. That dispatches the navigateToLogIn action where the current route is captured.
| if (currentUrl && currentUrl !== '/login') { | ||
| this.storageService.setReturnUrl(currentUrl); | ||
| } |
There was a problem hiding this comment.
When the user logs out they are sent to the logout complete page. From there if they click home to log back in the user will now be returned to the logout complete page following successful authentication. Thinking that maybe that could be avoided by updating the condition to ensure it doesn't equal /logout-complete. I haven't verified this though.
| @@ -75,6 +77,10 @@ export class CurrentUserEffects { | |||
| this.actions$.pipe( | |||
| ofType(UserActions.navigateToLogIn), | |||
| tap(() => { | |||
| const currentUrl = window.location.hash.substring(1) || this.router.url; | |||
There was a problem hiding this comment.
Also I don't think the router.url fallback here is correct. The application is configured with NavigationActionTiming.PostActivation which causes the router to not reflect until the route is activated after the guards complete. When dispatched from a guard this value will reflect the previous URL or undefined if it's a new window/tab.
Summary
NIFI-15393
Fixed login redirect issue where users were redirected to the home screen instead of their originally requested URL after authentication. The authentication flow now preserves the original destination URL and redirects users appropriately after login.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-15393NIFI-15393Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation