Redirect logged-in users from /login to /history

This commit is contained in:
Erik Michelson 2020-05-24 22:39:24 +02:00
parent 0071c81699
commit f5a851814a

View file

@ -9,11 +9,14 @@ import {ApplicationState} from "../../../../redux";
import {ViaOpenId} from "./auth/via-open id";
import "./login.scss";
import {ElementSeparator} from "../../../element-separator/element-separator";
import {Redirect} from "react-router";
import {LoginStatus} from "../../../../redux/user/types";
const Login: React.FC = () => {
useTranslation();
const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders);
const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames);
const userLoginState = useSelector((state: ApplicationState) => state.user.status);
const emailForm = authProviders.email ? <ViaEMail/> : null
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
const openIdForm = authProviders.openid ? <ViaOpenId/> : null
@ -28,6 +31,13 @@ const Login: React.FC = () => {
return undefined;
}
}
if (userLoginState === LoginStatus.ok) {
// TODO Redirect to previous page?
return (
<Redirect to='/history' />
)
}
return (
<Jumbotron className="bg-dark">