fix: Unneccessary redirect to /home

This commit is contained in:
Tom Moor 2020-07-11 09:51:10 -07:00
parent 5cb04d7ac1
commit 9951cbf194
1 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import User from "models/User";
import Team from "models/Team";
const AUTH_STORE = "AUTH_STORE";
const NO_REDIRECT_PATHS = ["/", "/create", "/home"];
type Service = {
id: string,
@ -112,7 +113,10 @@ export default class AuthStore {
const postLoginRedirectPath = getCookie("postLoginRedirectPath");
if (postLoginRedirectPath) {
removeCookie("postLoginRedirectPath");
window.location.href = postLoginRedirectPath;
if (!NO_REDIRECT_PATHS.includes(postLoginRedirectPath)) {
window.location.href = postLoginRedirectPath;
}
}
});
} catch (err) {
@ -190,7 +194,7 @@ export default class AuthStore {
if (savePath) {
const pathName = window.location.pathname;
if (pathName !== "/" && pathName !== "/create") {
if (!NO_REDIRECT_PATHS.includes(pathName)) {
setCookie("postLoginRedirectPath", pathName);
}
}