Web: Fixed redirection after login
This commit is contained in:
parent
fdb74c23af
commit
c62000f3f5
@ -55,6 +55,11 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||
|
||||
console.log("PrivateRoute render Redirect to login", rest);
|
||||
const redirectPath = wizardCompleted ? "/login" : "/wizard";
|
||||
|
||||
if (wizardCompleted && props.location.pathname !== "/") {
|
||||
sessionStorage.setItem("referenceUrl", window.location.href);
|
||||
}
|
||||
|
||||
return window.location.replace(redirectPath);
|
||||
// return (
|
||||
// <Redirect
|
||||
|
@ -97,7 +97,7 @@ function Editor({
|
||||
useEffect(() => {
|
||||
if (error && mfReady) {
|
||||
if (error?.unAuthorized) {
|
||||
localStorage.setItem("redirectPath", window.location.href);
|
||||
sessionStorage.setItem("referenceUrl", window.location.href);
|
||||
window.open(
|
||||
combineUrl(window.DocSpaceConfig?.proxy?.url, "/login"),
|
||||
"_self"
|
||||
|
@ -70,10 +70,10 @@ const LoginForm: React.FC<ILoginFormProps> = ({
|
||||
if (!response || !response.token) throw new Error("Empty API response");
|
||||
|
||||
setWithCredentialsStatus(true);
|
||||
const redirectPath = localStorage.getItem("redirectPath");
|
||||
const redirectPath = sessionStorage.getItem("referenceUrl");
|
||||
|
||||
if (redirectPath) {
|
||||
localStorage.removeItem("redirectPath");
|
||||
sessionStorage.removeItem("referenceUrl");
|
||||
window.location.href = redirectPath;
|
||||
}
|
||||
})
|
||||
@ -153,9 +153,9 @@ const LoginForm: React.FC<ILoginFormProps> = ({
|
||||
const session = !isChecked;
|
||||
login(user, hash, session)
|
||||
.then((res: string | object) => {
|
||||
const redirectPath = localStorage.getItem("redirectPath");
|
||||
const redirectPath = sessionStorage.getItem("referenceUrl");
|
||||
if (redirectPath) {
|
||||
localStorage.removeItem("redirectPath");
|
||||
sessionStorage.removeItem("referenceUrl");
|
||||
window.location.href = redirectPath;
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user