We're working with community non-profits who have a Host Home or empty bedrooms initiative to develop a workflow management tool to make the process scalable (across all providers), reduce institutional bias, and effectively capture data.
Updated the redirect when visiting protected outs from / to /signin
Removed the /profile path from the protected paths in the e2e tests since it no longer exists
Made /signout a protected route. I noticed it wasn't protected and therefore wasn't causing a token refresh if they were expired.
Rationale behind the changes?
I made these changes to correctly redirect the user based on 2 cases:
When the user logs out they are redirected to /
When the user tries to access a protected page. For example, when they aren’t logged in or logged in as a different user role they are redirected to the /signin in page
One issue I ran into was the ProtectedRoute component was redirecting the user after logging out instead of allowing us to choose the path. This was being caused by this line of code in app/src/components/common/AuthenticatedHeader.tsx:
The ProtectedRoute component relies on the user object to determine whether to navigate the user to /signin or render the necessary components. A change to the user object was causing the component to render<Navigate to="/signin" state={{from: location}} replace />; and override our call to navigate('/'). By removing the state update we can now redirect the user to the home page. However, the user object is still stored in state, but since the credentials are no longer valid the user can't log in or access any protected routes. The user object will also be reset anytime the user revisits the application or a protected endpoint.
Testing done for these changes
Updated Cypress tests to reflect the proper route redirects. There were also a lot of linter updates that were updated as well.
Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)
Visuals before changes are applied
![image](Paste_Your_Image_Link_Here_After_Attaching_Files)
Visuals after changes are applied
https://github.com/hackforla/HomeUniteUs/assets/27253583/68faddde-ba1c-4c92-97cf-924527676abc
Closes #645
What changes did you make?
/
to/signin
/profile
path from the protected paths in the e2e tests since it no longer exists/signout
a protected route. I noticed it wasn't protected and therefore wasn't causing a token refresh if they were expired.Rationale behind the changes?
I made these changes to correctly redirect the user based on 2 cases:
/
/signin
in pageOne issue I ran into was the
ProtectedRoute
component was redirecting the user after logging out instead of allowing us to choose the path. This was being caused by this line of code inapp/src/components/common/AuthenticatedHeader.tsx
:appDispatch(setCredentials({user: null, token: null}))
The
ProtectedRoute
component relies on the user object to determine whether to navigate the user to/signin
or render the necessary components. A change to the user object was causing the component to render<Navigate to="/signin" state={{from: location}} replace />;
and override our call tonavigate('/')
. By removing the state update we can now redirect the user to the home page. However, the user object is still stored in state, but since the credentials are no longer valid the user can't log in or access any protected routes. The user object will also be reset anytime the user revisits the application or a protected endpoint.Testing done for these changes
Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)
Visuals before changes are applied
![image](Paste_Your_Image_Link_Here_After_Attaching_Files)Visuals after changes are applied
https://github.com/hackforla/HomeUniteUs/assets/27253583/68faddde-ba1c-4c92-97cf-924527676abc