This commit is contained in:
Eduard Heimbuch
2020-08-10 09:28:54 +02:00
parent fa3f3bd135
commit 5e7739480b
2 changed files with 12 additions and 6 deletions

View File

@@ -61,12 +61,12 @@ class Main extends React.Component<Props> {
if (authenticated) {
url = "/repos/";
}
if (!me) {
url = "/login";
}
if (redirectUrlFactory) {
url = redirectUrlFactory(this.props);
}
if (!me) {
url = "/login";
}
return (
<div className="main">
<Switch>
@@ -95,6 +95,7 @@ class Main extends React.Component<Props> {
renderAll={true}
props={{
authenticated,
me,
links
}}
/>

View File

@@ -23,7 +23,7 @@
*/
import React from "react";
import { Route, RouteComponentProps, withRouter } from "react-router-dom";
import { getMe, isAnonymous } from "../modules/auth";
import { getMe } from "../modules/auth";
import { compose } from "redux";
import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next";
@@ -63,6 +63,11 @@ class Profile extends React.Component<Props> {
return this.stripEndingSlash(this.props.match.url);
};
mayChangePassword = () => {
const { me } = this.props;
return !!me?._links?.password;
}
render() {
const url = this.matchedUrl();
@@ -92,7 +97,7 @@ class Profile extends React.Component<Props> {
<CustomQueryFlexWrappedColumns>
<PrimaryContentColumn>
<Route path={url} exact render={() => <ProfileInfo me={me} />} />
{me?._links?.password && (
{this.mayChangePassword() && (
<Route path={`${url}/settings/password`} render={() => <ChangeUserPassword me={me} />} />
)}
<ExtensionPoint name="profile.route" props={extensionProps} renderAll={true} />
@@ -105,7 +110,7 @@ class Profile extends React.Component<Props> {
label={t("profile.informationNavLink")}
title={t("profile.informationNavLink")}
/>
{!isAnonymous(me) && (
{this.mayChangePassword() && (
<SubNavigation
to={`${url}/settings/password`}
label={t("profile.settingsNavLink")}