-
Notifications
You must be signed in to change notification settings - Fork 168
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
Conversation
@@ -37,7 +37,15 @@ export const login = args => { | |||
payload: { token: res.key }, | |||
}); | |||
}) | |||
.then(() => args.history.push('/')); | |||
.then(() => { | |||
const initialUrl = sessionStorage.getItem('initialUrl'); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this 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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😏
There was a problem hiding this comment.
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.
* 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]>
* 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]>
Summary
Save the
initalUrl
in thesessionStorage
when logging out and removes it immediately after logging inCloses #924
Changes
initialUrl
in sessionStorageScreencasts
Screencast.from.2023-10-20.08-30-06.webm