Skip to content
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

bug/WP-287: Remove login url redirect to profile data #904

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

shayanaijaz
Copy link
Contributor

@shayanaijaz shayanaijaz commented Nov 20, 2023

Overview

Fixes the bug where in certain cases after logging in the user would be redirected to the /api/profile/data path and see a screen with api data text.

Related

Changes

  • Removed an extra GET_PROFILE_DATA action that was being dispatched in AppRouter.jsx.
  • Cleaned up tests for Allocations components by removing unused variables

Background

The profile data retrieved is added to the profile state variable. This state is only used in the ManageAccount components and ManageAccount.jsx already has a GET_PROFILE_DATA action being dispatched. So the data is available in that component and removing the action from the AppRouter does not have an effect here.

Previously, the GET_PROFILE_DATA was added in the AppRouter.jsx as part of this PR which was using the profile state to retrieve user information to display in Allocations tables (see AllocationsTable and AllocationsTeamViewModal).

In a later PR the usage of profile was removed from the Allocations components (see AllocationsTable and AllocationsTeamViewModal) However, that added GET_PROFILE_DATA action was not removed. Since the profile information is not being used in the Allocations components, the additional action being dispatched in AppRouter should be safe to remove

Testing

  1. While logged out go to cep.test/public-data/
  2. Log In and go through the flow and ensure page gets redirected to the My Account page

For reference, this was the flow before the fix:

Screen.Recording.2023-11-17.at.4.21.21.PM.mov

UI

Notes

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #904 (cb97ae7) into main (1af7c8f) will decrease coverage by 0.01%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #904      +/-   ##
==========================================
- Coverage   63.41%   63.41%   -0.01%     
==========================================
  Files         432      432              
  Lines       12393    12392       -1     
  Branches     2581     2581              
==========================================
- Hits         7859     7858       -1     
  Misses       4324     4324              
  Partials      210      210              
Flag Coverage Δ
javascript 69.75% <ø> (-0.01%) ⬇️
unittests 56.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/src/components/Workbench/AppRouter.jsx 100.00% <ø> (ø)

@shayanaijaz shayanaijaz marked this pull request as ready for review November 20, 2023 16:50
Copy link
Contributor

@edmondsgarrett edmondsgarrett left a comment

Choose a reason for hiding this comment

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

LGTM, working well!

Copy link
Collaborator

@chandra-tacc chandra-tacc left a comment

Choose a reason for hiding this comment

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

Tested on dev.cep( the branch is deployed there right now).
No longer see the redirect on the specific repro.

I think we need more analysis on allowing only use of certain defined routes as part of 'next' parameter. How did a non-route-page like profile end up on next?I haven't checked the details, but will look into it now.

Copy link
Member

@rstijerina rstijerina left a comment

Choose a reason for hiding this comment

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

This fixes this specific issue 👍

I think a good long term solution to avoid similar cases would be to change this:

    redirect = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
    if 'next' in request.session:
        redirect += '?next=' + request.session.pop('next')

    response = HttpResponseRedirect(redirect)
    return response

to this:

    redirect = getattr(settings, 'LOGIN_REDIRECT_URL', '/')

    response = HttpResponseRedirect(redirect)
    return response

@rstijerina rstijerina merged commit 3f1471e into main Nov 20, 2023
6 checks passed
@rstijerina rstijerina deleted the bug/WP-287--fix-api-redirect branch November 20, 2023 19:37
@chandra-tacc chandra-tacc changed the title bug/WP-287 Fix Invalid Url Redirect bug/WP-287: Remove login url redirect to profile data Nov 27, 2023
@chandra-tacc
Copy link
Collaborator

This fixes this specific issue 👍

I think a good long term solution to avoid similar cases would be to change this:

    redirect = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
    if 'next' in request.session:
        redirect += '?next=' + request.session.pop('next')

    response = HttpResponseRedirect(redirect)
    return response

to this:

    redirect = getattr(settings, 'LOGIN_REDIRECT_URL', '/')

    response = HttpResponseRedirect(redirect)
    return response

Tracking task: WP-395

chandra-tacc pushed a commit that referenced this pull request Dec 8, 2023
* remove extra get profile data call

* fix tests
chandra-tacc pushed a commit that referenced this pull request Dec 8, 2023
* remove extra get profile data call

* fix tests
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.

4 participants