fix redirects on protected routes for anonymous user

This commit is contained in:
Eduard Heimbuch
2020-08-04 09:39:37 +02:00
parent 4c9e96f7e2
commit c8a111f78e
4 changed files with 13 additions and 10 deletions

View File

@@ -68,7 +68,7 @@ class App extends Component<Props> {
content = <Loading />;
} else if (error) {
content = <ErrorPage title={t("app.error.title")} subtitle={t("app.error.subtitle")} error={error} />;
} else {
} else if (me) {
content = <Main authenticated={authenticated} links={links} />;
}
return (

View File

@@ -26,9 +26,9 @@ import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next";
import { Redirect } from "react-router-dom";
import { getLogoutFailure, isAuthenticated, isLogoutPending, isRedirecting, logout } from "../modules/auth";
import { getLogoutFailure, isLogoutPending, isRedirecting, logout } from "../modules/auth";
import { ErrorPage, Loading } from "@scm-manager/ui-components";
import { getLogoutLink } from "../modules/indexResource";
import { getLoginLink, getLogoutLink } from "../modules/indexResource";
type Props = WithTranslation & {
authenticated: boolean;
@@ -61,7 +61,7 @@ class Logout extends React.Component<Props> {
}
const mapStateToProps = (state: any) => {
const authenticated = isAuthenticated(state);
const authenticated = state.auth.me && !getLoginLink(state);
const loading = isLogoutPending(state);
const redirecting = isRedirecting(state);
const error = getLogoutFailure(state);