add anonymous mode for webclient / change footer and redirects if user is anonymous / add login button if user is anonymous

This commit is contained in:
Eduard Heimbuch
2020-08-03 17:41:40 +02:00
parent b926238e03
commit 4c9e96f7e2
21 changed files with 324 additions and 151 deletions

View File

@@ -26,7 +26,7 @@ import { connect } from "react-redux";
import { Redirect, withRouter } from "react-router-dom";
import { compose } from "redux";
import styled from "styled-components";
import { getLoginFailure, isAuthenticated, isLoginPending, login } from "../modules/auth";
import { getLoginFailure, isAnonymous, isLoginPending, login } from "../modules/auth";
import { getLoginInfoLink, getLoginLink } from "../modules/indexResource";
import LoginInfo from "../components/LoginInfo";
@@ -86,7 +86,7 @@ class Login extends React.Component<Props> {
}
const mapStateToProps = (state: any) => {
const authenticated = isAuthenticated(state);
const authenticated = state?.auth?.me && !isAnonymous(state.auth.me);
const loading = isLoginPending(state);
const error = getLoginFailure(state);
const link = getLoginLink(state);

View File

@@ -43,7 +43,9 @@ type Props = WithTranslation & {
class Logout extends React.Component<Props> {
componentDidMount() {
this.props.logout(this.props.logoutLink);
if (this.props.logoutLink) {
this.props.logout(this.props.logoutLink);
}
}
render() {

View File

@@ -23,7 +23,7 @@
*/
import React from "react";
import { Route, RouteComponentProps, withRouter } from "react-router-dom";
import { getMe } from "../modules/auth";
import { getMe, isAnonymous } from "../modules/auth";
import { compose } from "redux";
import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next";
@@ -92,7 +92,9 @@ class Profile extends React.Component<Props> {
<CustomQueryFlexWrappedColumns>
<PrimaryContentColumn>
<Route path={url} exact render={() => <ProfileInfo me={me} />} />
<Route path={`${url}/settings/password`} render={() => <ChangeUserPassword me={me} />} />
{me?._links?.password && (
<Route path={`${url}/settings/password`} render={() => <ChangeUserPassword me={me} />} />
)}
<ExtensionPoint name="profile.route" props={extensionProps} renderAll={true} />
</PrimaryContentColumn>
<SecondaryNavigationColumn>
@@ -103,14 +105,16 @@ class Profile extends React.Component<Props> {
label={t("profile.informationNavLink")}
title={t("profile.informationNavLink")}
/>
<SubNavigation
to={`${url}/settings/password`}
label={t("profile.settingsNavLink")}
title={t("profile.settingsNavLink")}
>
<NavLink to={`${url}/settings/password`} label={t("profile.changePasswordNavLink")} />
<ExtensionPoint name="profile.setting" props={extensionProps} renderAll={true} />
</SubNavigation>
{!isAnonymous(me) && (
<SubNavigation
to={`${url}/settings/password`}
label={t("profile.settingsNavLink")}
title={t("profile.settingsNavLink")}
>
<NavLink to={`${url}/settings/password`} label={t("profile.changePasswordNavLink")} />
<ExtensionPoint name="profile.setting" props={extensionProps} renderAll={true} />
</SubNavigation>
)}
</SecondaryNavigation>
</SecondaryNavigationColumn>
</CustomQueryFlexWrappedColumns>