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