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

(feat) Redirect users to the page they were on before being logged out #931

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

coderatomy
Copy link
Collaborator

@coderatomy coderatomy commented Oct 20, 2023

Summary

Save the initalUrl in the sessionStorage when logging out and removes it immediately after logging in
Closes #924

Changes

  • Save the initialUrl in sessionStorage

Screencasts

Screencast.from.2023-10-20.08-30-06.webm

@@ -37,7 +37,15 @@ export const login = args => {
payload: { token: res.key },
});
})
.then(() => args.history.push('/'));
.then(() => {
const initialUrl = sessionStorage.getItem('initialUrl');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getting the initailUrl from the sessionStorage

@@ -124,6 +124,9 @@ class API {
* @todo - describe method's signature
*/
logout = token => {
const initialUrl = window.location.href
sessionStorage.setItem('initialUrl', initialUrl)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

saving the initialUrl in sessionStorage when logging out

Copy link
Member

@tuxology tuxology left a comment

Choose a reason for hiding this comment

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

LGTM 🌈

@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { withTranslation } from 'react-i18next';
import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom';
import CreateActivity from './views/create_activity/create_activity';
import CreateActivity from './views/create_activity/CreateActivity';
Copy link
Member

Choose a reason for hiding this comment

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

😏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Won't conflict. I merged the regression commit into this since it was blocking.

@tuxology tuxology merged commit a558469 into unstructuredstudio:master Oct 20, 2023
@coderatomy coderatomy mentioned this pull request Nov 12, 2023
NdibeRaymond pushed a commit that referenced this pull request May 19, 2024
* fix routing
* fix pagewrapper
* remove previous protected route features
  and reimplement (was defective)
* revert #931 (implementation is defective)
* implement redirection feature (
  when you try to visit a protected route,
  you get redirected to the login page
  instead of the pagenotfound error,
  and after logging in you get redirected
  back to the protected page you initially
  wanted to visit)

Issue: #1127
Signed-off-by: Ndibe Raymond Olisaemeka <[email protected]>
@NdibeRaymond NdibeRaymond mentioned this pull request May 19, 2024
NdibeRaymond added a commit that referenced this pull request May 19, 2024
* fix routing
* fix pagewrapper
* remove previous protected route features
  and reimplement (was defective)
* revert #931 (implementation is defective)
* implement redirection feature (
  when you try to visit a protected route,
  you get redirected to the login page
  instead of the pagenotfound error,
  and after logging in you get redirected
  back to the protected page you initially
  wanted to visit)

Issue: #1127

Signed-off-by: Ndibe Raymond Olisaemeka <[email protected]>
Co-authored-by: Ndibe Raymond Olisaemeka <[email protected]>
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.

Redirect users to the page they were on before being logged out
2 participants