2022-02-13 23:39:27 +08:00
|
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2020-10-20 22:37:38 +08:00
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
import React, {Component} from 'react';
|
2021-03-26 23:18:24 +08:00
|
|
|
|
import './App.less';
|
2021-04-29 19:51:03 +08:00
|
|
|
|
import {Helmet} from "react-helmet";
|
2020-10-20 22:37:38 +08:00
|
|
|
|
import * as Setting from "./Setting";
|
|
|
|
|
import {DownOutlined, LogoutOutlined, SettingOutlined} from '@ant-design/icons';
|
2021-08-06 18:03:05 +08:00
|
|
|
|
import {Avatar, BackTop, Dropdown, Layout, Menu, Card, Result, Button} from 'antd';
|
2021-03-28 16:35:59 +08:00
|
|
|
|
import {Link, Redirect, Route, Switch, withRouter} from 'react-router-dom'
|
2020-12-20 20:31:48 +08:00
|
|
|
|
import OrganizationListPage from "./OrganizationListPage";
|
|
|
|
|
import OrganizationEditPage from "./OrganizationEditPage";
|
2020-10-20 23:14:03 +08:00
|
|
|
|
import UserListPage from "./UserListPage";
|
|
|
|
|
import UserEditPage from "./UserEditPage";
|
2022-01-01 15:11:16 +08:00
|
|
|
|
import RoleListPage from "./RoleListPage";
|
|
|
|
|
import RoleEditPage from "./RoleEditPage";
|
2022-01-01 16:28:06 +08:00
|
|
|
|
import PermissionListPage from "./PermissionListPage";
|
|
|
|
|
import PermissionEditPage from "./PermissionEditPage";
|
2020-12-20 21:25:23 +08:00
|
|
|
|
import ProviderListPage from "./ProviderListPage";
|
|
|
|
|
import ProviderEditPage from "./ProviderEditPage";
|
2020-12-20 23:24:09 +08:00
|
|
|
|
import ApplicationListPage from "./ApplicationListPage";
|
|
|
|
|
import ApplicationEditPage from "./ApplicationEditPage";
|
2021-08-15 00:17:53 +08:00
|
|
|
|
import ResourceListPage from "./ResourceListPage";
|
2021-07-17 14:13:00 +08:00
|
|
|
|
import LdapEditPage from "./LdapEditPage";
|
|
|
|
|
import LdapSyncPage from "./LdapSyncPage";
|
2021-03-13 23:47:35 +08:00
|
|
|
|
import TokenListPage from "./TokenListPage";
|
|
|
|
|
import TokenEditPage from "./TokenEditPage";
|
2021-07-07 14:59:03 +08:00
|
|
|
|
import RecordListPage from "./RecordListPage";
|
2021-11-07 15:41:24 +08:00
|
|
|
|
import WebhookListPage from "./WebhookListPage";
|
|
|
|
|
import WebhookEditPage from "./WebhookEditPage";
|
2021-12-17 16:32:53 +08:00
|
|
|
|
import SyncerListPage from "./SyncerListPage";
|
|
|
|
|
import SyncerEditPage from "./SyncerEditPage";
|
2021-12-31 00:36:36 +08:00
|
|
|
|
import CertListPage from "./CertListPage";
|
|
|
|
|
import CertEditPage from "./CertEditPage";
|
2022-02-27 18:20:58 +08:00
|
|
|
|
import ProductListPage from "./ProductListPage";
|
|
|
|
|
import ProductEditPage from "./ProductEditPage";
|
2022-02-27 23:50:35 +08:00
|
|
|
|
import ProductBuyPage from "./ProductBuyPage";
|
2022-02-05 01:18:13 +08:00
|
|
|
|
import PaymentListPage from "./PaymentListPage";
|
|
|
|
|
import PaymentEditPage from "./PaymentEditPage";
|
2022-03-13 18:05:16 +08:00
|
|
|
|
import PaymentResultPage from "./PaymentResultPage";
|
2021-02-13 01:33:06 +08:00
|
|
|
|
import AccountPage from "./account/AccountPage";
|
2021-02-13 17:34:32 +08:00
|
|
|
|
import HomePage from "./basic/HomePage";
|
2021-08-07 19:52:01 +08:00
|
|
|
|
import CustomGithubCorner from "./CustomGithubCorner";
|
2022-03-05 23:51:55 +08:00
|
|
|
|
import * as Conf from "./Conf";
|
2021-02-14 15:40:57 +08:00
|
|
|
|
|
2021-02-14 16:59:08 +08:00
|
|
|
|
import * as Auth from "./auth/Auth";
|
2021-04-27 22:47:44 +08:00
|
|
|
|
import SignupPage from "./auth/SignupPage";
|
2021-03-26 21:57:41 +08:00
|
|
|
|
import ResultPage from "./auth/ResultPage";
|
2021-03-26 21:56:51 +08:00
|
|
|
|
import LoginPage from "./auth/LoginPage";
|
2021-03-26 21:56:27 +08:00
|
|
|
|
import SelfLoginPage from "./auth/SelfLoginPage";
|
2021-06-02 13:39:01 +08:00
|
|
|
|
import SelfForgetPage from "./auth/SelfForgetPage";
|
|
|
|
|
import ForgetPage from "./auth/ForgetPage";
|
2021-02-14 15:40:57 +08:00
|
|
|
|
import * as AuthBackend from "./auth/AuthBackend";
|
2021-02-14 14:34:03 +08:00
|
|
|
|
import AuthCallback from "./auth/AuthCallback";
|
2021-02-19 23:23:59 +08:00
|
|
|
|
import SelectLanguageBox from './SelectLanguageBox';
|
|
|
|
|
import i18next from 'i18next';
|
2021-06-18 02:05:19 +08:00
|
|
|
|
import PromptPage from "./auth/PromptPage";
|
2021-09-25 14:54:13 +08:00
|
|
|
|
import OdicDiscoveryPage from "./auth/OidcDiscoveryPage";
|
2021-12-06 21:46:50 +08:00
|
|
|
|
import SamlCallback from './auth/SamlCallback';
|
2022-04-04 00:09:04 +08:00
|
|
|
|
import CasLogout from "./auth/CasLogout";
|
2020-10-20 22:37:38 +08:00
|
|
|
|
|
2021-07-25 11:10:45 +08:00
|
|
|
|
const { Header, Footer } = Layout;
|
2020-10-20 22:37:38 +08:00
|
|
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
classes: props,
|
|
|
|
|
selectedMenuKey: 0,
|
|
|
|
|
account: undefined,
|
2021-03-26 21:57:41 +08:00
|
|
|
|
uri: null,
|
2020-10-20 22:37:38 +08:00
|
|
|
|
};
|
2020-10-20 23:14:03 +08:00
|
|
|
|
|
|
|
|
|
Setting.initServerUrl();
|
2021-02-14 16:59:08 +08:00
|
|
|
|
Auth.initAuthWithConfig({
|
|
|
|
|
serverUrl: Setting.ServerUrl,
|
2021-12-13 16:42:46 +08:00
|
|
|
|
appName: "app-built-in", // the application name of Casdoor itself, do not change it
|
2021-02-14 16:59:08 +08:00
|
|
|
|
});
|
2020-10-20 22:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-27 11:38:15 +08:00
|
|
|
|
UNSAFE_componentWillMount() {
|
2020-10-20 22:37:38 +08:00
|
|
|
|
this.updateMenuKey();
|
|
|
|
|
this.getAccount();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-26 21:57:41 +08:00
|
|
|
|
componentDidUpdate() {
|
|
|
|
|
// eslint-disable-next-line no-restricted-globals
|
|
|
|
|
const uri = location.pathname;
|
|
|
|
|
if (this.state.uri !== uri) {
|
|
|
|
|
this.updateMenuKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
updateMenuKey() {
|
|
|
|
|
// eslint-disable-next-line no-restricted-globals
|
|
|
|
|
const uri = location.pathname;
|
2021-03-26 21:57:41 +08:00
|
|
|
|
this.setState({
|
|
|
|
|
uri: uri,
|
|
|
|
|
});
|
2020-10-20 22:37:38 +08:00
|
|
|
|
if (uri === '/') {
|
2021-07-27 18:43:55 +08:00
|
|
|
|
this.setState({ selectedMenuKey: '/' });
|
|
|
|
|
} else if (uri.includes('/organizations')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/organizations' });
|
|
|
|
|
} else if (uri.includes('/users')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/users' });
|
2022-01-01 15:11:16 +08:00
|
|
|
|
} else if (uri.includes('/roles')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/roles' });
|
2022-01-01 16:28:06 +08:00
|
|
|
|
} else if (uri.includes('/permissions')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/permissions' });
|
2021-07-27 18:43:55 +08:00
|
|
|
|
} else if (uri.includes('/providers')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/providers' });
|
|
|
|
|
} else if (uri.includes('/applications')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/applications' });
|
2021-08-15 00:17:53 +08:00
|
|
|
|
} else if (uri.includes('/resources')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/resources' });
|
2021-07-27 18:43:55 +08:00
|
|
|
|
} else if (uri.includes('/tokens')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/tokens' });
|
|
|
|
|
} else if (uri.includes('/records')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/records' });
|
2021-11-07 15:41:24 +08:00
|
|
|
|
} else if (uri.includes('/webhooks')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/webhooks' });
|
2021-12-17 16:32:53 +08:00
|
|
|
|
} else if (uri.includes('/syncers')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/syncers' });
|
2021-12-31 00:36:36 +08:00
|
|
|
|
} else if (uri.includes('/certs')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/certs' });
|
2022-02-27 18:20:58 +08:00
|
|
|
|
} else if (uri.includes('/products')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/products' });
|
2022-02-05 01:18:13 +08:00
|
|
|
|
} else if (uri.includes('/payments')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/payments' });
|
2021-07-27 18:43:55 +08:00
|
|
|
|
} else if (uri.includes('/signup')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/signup' });
|
|
|
|
|
} else if (uri.includes('/login')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/login' });
|
|
|
|
|
} else if (uri.includes('/result')) {
|
|
|
|
|
this.setState({ selectedMenuKey: '/result' });
|
2020-10-20 22:37:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
this.setState({ selectedMenuKey: -1 });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-28 21:33:10 +08:00
|
|
|
|
getAccessTokenParam(params) {
|
2021-03-28 16:35:59 +08:00
|
|
|
|
// "/page?access_token=123"
|
2021-05-16 18:18:55 +08:00
|
|
|
|
const accessToken = params.get("access_token");
|
|
|
|
|
return accessToken === null ? "" : `?accessToken=${accessToken}`;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-28 21:33:10 +08:00
|
|
|
|
getCredentialParams(params) {
|
2021-05-16 18:18:55 +08:00
|
|
|
|
// "/page?username=abc&password=123"
|
|
|
|
|
if (params.get("username") === null || params.get("password") === null) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return `?username=${params.get("username")}&password=${params.get("password")}`;
|
2021-03-28 16:35:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getUrlWithoutQuery() {
|
2022-02-28 21:33:10 +08:00
|
|
|
|
return window.location.toString().replace(window.location.search, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLanguageParam(params) {
|
|
|
|
|
// "/page?language=en"
|
|
|
|
|
const language = params.get("language");
|
|
|
|
|
if (language !== null) {
|
|
|
|
|
Setting.setLanguage(language);
|
|
|
|
|
return `language=${language}`;
|
|
|
|
|
}
|
|
|
|
|
return "";
|
2021-03-28 16:35:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 01:22:13 +08:00
|
|
|
|
setLanguage(account) {
|
|
|
|
|
let language = account?.language;
|
|
|
|
|
if (language !== "" && language !== i18next.language) {
|
|
|
|
|
Setting.setLanguage(language);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
getAccount() {
|
2022-02-28 21:33:10 +08:00
|
|
|
|
const params = new URLSearchParams(this.props.location.search);
|
|
|
|
|
|
|
|
|
|
let query = this.getAccessTokenParam(params);
|
2021-05-16 18:18:55 +08:00
|
|
|
|
if (query === "") {
|
2022-02-28 21:33:10 +08:00
|
|
|
|
query = this.getCredentialParams(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const query2 = this.getLanguageParam(params);
|
|
|
|
|
if (query2 !== "") {
|
|
|
|
|
const url = window.location.toString().replace(new RegExp(`[?&]${query2}`), "");
|
|
|
|
|
window.history.replaceState({}, document.title, url);
|
2021-05-16 18:18:55 +08:00
|
|
|
|
}
|
2022-02-28 21:33:10 +08:00
|
|
|
|
|
2021-05-16 18:18:55 +08:00
|
|
|
|
if (query !== "") {
|
2021-03-28 16:35:59 +08:00
|
|
|
|
window.history.replaceState({}, document.title, this.getUrlWithoutQuery());
|
|
|
|
|
}
|
2022-02-28 21:33:10 +08:00
|
|
|
|
|
2021-05-16 18:18:55 +08:00
|
|
|
|
AuthBackend.getAccount(query)
|
2020-10-20 22:37:38 +08:00
|
|
|
|
.then((res) => {
|
2021-04-29 19:51:03 +08:00
|
|
|
|
let account = null;
|
|
|
|
|
if (res.status === "ok") {
|
|
|
|
|
account = res.data;
|
|
|
|
|
account.organization = res.data2;
|
2021-09-14 01:22:13 +08:00
|
|
|
|
|
|
|
|
|
this.setLanguage(account);
|
2021-05-15 23:34:06 +08:00
|
|
|
|
} else {
|
2021-05-16 18:18:55 +08:00
|
|
|
|
if (res.msg !== "Please sign in first") {
|
2021-05-15 23:34:06 +08:00
|
|
|
|
Setting.showMessage("error", `Failed to sign in: ${res.msg}`);
|
|
|
|
|
}
|
2021-04-29 19:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
this.setState({
|
2021-04-29 19:51:03 +08:00
|
|
|
|
account: account,
|
2020-10-20 22:37:38 +08:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logout() {
|
|
|
|
|
this.setState({
|
|
|
|
|
expired: false,
|
|
|
|
|
submitted: false,
|
|
|
|
|
});
|
|
|
|
|
|
2021-02-14 15:40:57 +08:00
|
|
|
|
AuthBackend.logout()
|
2020-10-20 22:37:38 +08:00
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.status === 'ok') {
|
|
|
|
|
this.setState({
|
|
|
|
|
account: null
|
|
|
|
|
});
|
|
|
|
|
|
2021-03-28 21:18:41 +08:00
|
|
|
|
Setting.showMessage("success", `Logged out successfully`);
|
2022-03-19 19:50:05 +08:00
|
|
|
|
let redirectUri = res.data2;
|
|
|
|
|
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
|
|
|
|
Setting.goToLink(redirectUri);
|
|
|
|
|
}else{
|
|
|
|
|
Setting.goToLinkSoft(this, "/");
|
|
|
|
|
}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
} else {
|
2021-03-26 21:57:41 +08:00
|
|
|
|
Setting.showMessage("error", `Failed to log out: ${res.msg}`);
|
2020-10-20 22:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-20 13:27:26 +08:00
|
|
|
|
onUpdateAccount(account) {
|
|
|
|
|
this.setState({
|
|
|
|
|
account: account
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
handleRightDropdownClick(e) {
|
2021-09-13 23:55:42 +08:00
|
|
|
|
if (e.key === '/account') {
|
2020-10-20 22:37:38 +08:00
|
|
|
|
this.props.history.push(`/account`);
|
2021-09-14 01:22:13 +08:00
|
|
|
|
} else if (e.key === '/logout') {
|
2020-10-20 22:37:38 +08:00
|
|
|
|
this.logout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-28 21:18:41 +08:00
|
|
|
|
renderAvatar() {
|
|
|
|
|
if (this.state.account.avatar === "") {
|
|
|
|
|
return (
|
|
|
|
|
<Avatar style={{ backgroundColor: Setting.getAvatarColor(this.state.account.name), verticalAlign: 'middle' }} size="large">
|
|
|
|
|
{Setting.getShortName(this.state.account.name)}
|
|
|
|
|
</Avatar>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<Avatar src={this.state.account.avatar} style={{verticalAlign: 'middle' }} size="large">
|
|
|
|
|
{Setting.getShortName(this.state.account.name)}
|
|
|
|
|
</Avatar>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
renderRightDropdown() {
|
|
|
|
|
const menu = (
|
|
|
|
|
<Menu onClick={this.handleRightDropdownClick.bind(this)}>
|
2021-09-13 23:55:42 +08:00
|
|
|
|
<Menu.Item key="/account">
|
2020-10-20 22:37:38 +08:00
|
|
|
|
<SettingOutlined />
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("account:My Account")}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
</Menu.Item>
|
2021-09-13 23:55:42 +08:00
|
|
|
|
<Menu.Item key="/logout">
|
2020-10-20 22:37:38 +08:00
|
|
|
|
<LogoutOutlined />
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("account:Logout")}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
</Menu.Item>
|
|
|
|
|
</Menu>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
2021-09-13 23:55:42 +08:00
|
|
|
|
<Dropdown key="/rightDropDown" overlay={menu} className="rightDropDown">
|
2021-03-27 11:38:15 +08:00
|
|
|
|
<div className="ant-dropdown-link" style={{float: 'right', cursor: 'pointer'}}>
|
2021-07-23 09:46:01 +08:00
|
|
|
|
|
|
|
|
|
|
2021-03-28 21:18:41 +08:00
|
|
|
|
{
|
|
|
|
|
this.renderAvatar()
|
|
|
|
|
}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
|
|
|
|
|
|
2021-04-27 20:42:19 +08:00
|
|
|
|
{Setting.isMobile() ? null : Setting.getShortName(this.state.account.displayName)} <DownOutlined />
|
2020-10-20 22:37:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-27 11:38:15 +08:00
|
|
|
|
</div>
|
2020-10-20 22:37:38 +08:00
|
|
|
|
</Dropdown>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderAccount() {
|
|
|
|
|
let res = [];
|
|
|
|
|
|
2021-02-14 00:22:24 +08:00
|
|
|
|
if (this.state.account === undefined) {
|
|
|
|
|
return null;
|
|
|
|
|
} else if (this.state.account === null) {
|
2021-05-08 00:23:08 +08:00
|
|
|
|
// res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
// <Menu.Item key="/signup" style={{float: 'right', marginRight: '20px'}}>
|
2021-05-08 00:23:08 +08:00
|
|
|
|
// <Link to="/signup">
|
|
|
|
|
// {i18next.t("account:Sign Up")}
|
|
|
|
|
// </Link>
|
|
|
|
|
// </Menu.Item>
|
|
|
|
|
// );
|
|
|
|
|
// res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
// <Menu.Item key="/login" style={{float: 'right'}}>
|
2021-05-08 00:23:08 +08:00
|
|
|
|
// <Link to="/login">
|
|
|
|
|
// {i18next.t("account:Login")}
|
|
|
|
|
// </Link>
|
|
|
|
|
// </Menu.Item>
|
|
|
|
|
// );
|
2021-02-14 00:22:24 +08:00
|
|
|
|
} else {
|
|
|
|
|
res.push(this.renderRightDropdown());
|
2020-10-20 22:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderMenu() {
|
|
|
|
|
let res = [];
|
|
|
|
|
|
2021-02-13 01:33:06 +08:00
|
|
|
|
if (this.state.account === null || this.state.account === undefined) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
|
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/">
|
2021-02-12 00:31:53 +08:00
|
|
|
|
<Link to="/">
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("general:Home")}
|
2021-02-12 00:31:53 +08:00
|
|
|
|
</Link>
|
2020-10-20 22:37:38 +08:00
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-02-15 22:14:19 +08:00
|
|
|
|
|
|
|
|
|
if (Setting.isAdminUser(this.state.account)) {
|
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/organizations">
|
2021-02-15 22:14:19 +08:00
|
|
|
|
<Link to="/organizations">
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("general:Organizations")}
|
2021-02-15 22:14:19 +08:00
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/users">
|
2021-02-15 22:14:19 +08:00
|
|
|
|
<Link to="/users">
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("general:Users")}
|
2021-02-15 22:14:19 +08:00
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2022-01-01 15:11:16 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/roles">
|
|
|
|
|
<Link to="/roles">
|
|
|
|
|
{i18next.t("general:Roles")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2022-01-01 16:28:06 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/permissions">
|
|
|
|
|
<Link to="/permissions">
|
|
|
|
|
{i18next.t("general:Permissions")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-02-15 22:14:19 +08:00
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/providers">
|
2021-02-15 22:14:19 +08:00
|
|
|
|
<Link to="/providers">
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("general:Providers")}
|
2021-02-15 22:14:19 +08:00
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/applications">
|
2021-02-15 22:14:19 +08:00
|
|
|
|
<Link to="/applications">
|
2021-02-19 23:23:59 +08:00
|
|
|
|
{i18next.t("general:Applications")}
|
2021-02-15 22:14:19 +08:00
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-09-06 00:49:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Setting.isAdminUser(this.state.account)) {
|
2021-09-21 17:35:59 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/resources">
|
|
|
|
|
<Link to="/resources">
|
|
|
|
|
{i18next.t("general:Resources")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-03-13 23:47:35 +08:00
|
|
|
|
res.push(
|
2021-07-27 18:43:55 +08:00
|
|
|
|
<Menu.Item key="/tokens">
|
2021-03-13 23:47:35 +08:00
|
|
|
|
<Link to="/tokens">
|
|
|
|
|
{i18next.t("general:Tokens")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-07-07 14:59:03 +08:00
|
|
|
|
res.push(
|
2021-09-06 00:49:10 +08:00
|
|
|
|
<Menu.Item key="/records">
|
|
|
|
|
<Link to="/records">
|
|
|
|
|
{i18next.t("general:Records")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
2021-07-07 14:59:03 +08:00
|
|
|
|
);
|
2021-11-07 15:41:24 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/webhooks">
|
|
|
|
|
<Link to="/webhooks">
|
|
|
|
|
{i18next.t("general:Webhooks")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-12-17 16:32:53 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/syncers">
|
|
|
|
|
<Link to="/syncers">
|
|
|
|
|
{i18next.t("general:Syncers")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-12-31 00:36:36 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/certs">
|
|
|
|
|
<Link to="/certs">
|
|
|
|
|
{i18next.t("general:Certs")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2022-03-05 23:51:55 +08:00
|
|
|
|
|
|
|
|
|
if (Conf.EnableExtraPages) {
|
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/products">
|
|
|
|
|
<Link to="/products">
|
|
|
|
|
{i18next.t("general:Products")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/payments">
|
|
|
|
|
<Link to="/payments">
|
|
|
|
|
{i18next.t("general:Payments")}
|
|
|
|
|
</Link>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 17:35:59 +08:00
|
|
|
|
res.push(
|
|
|
|
|
<Menu.Item key="/swagger">
|
2022-02-04 20:00:40 +08:00
|
|
|
|
<a target="_blank" rel="noreferrer" href={Setting.isLocalhost() ? `${Setting.ServerUrl}/swagger` : "/swagger"}>
|
2021-09-21 17:35:59 +08:00
|
|
|
|
{i18next.t("general:Swagger")}
|
|
|
|
|
</a>
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
);
|
2021-02-15 22:14:19 +08:00
|
|
|
|
}
|
2021-09-06 00:49:10 +08:00
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-13 01:33:06 +08:00
|
|
|
|
renderHomeIfLoggedIn(component) {
|
2020-10-20 22:37:38 +08:00
|
|
|
|
if (this.state.account !== null && this.state.account !== undefined) {
|
|
|
|
|
return <Redirect to='/' />
|
|
|
|
|
} else {
|
|
|
|
|
return component;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-13 00:11:12 +08:00
|
|
|
|
renderLoginIfNotLoggedIn(component) {
|
2020-10-20 22:37:38 +08:00
|
|
|
|
if (this.state.account === null) {
|
2022-02-12 09:55:06 +08:00
|
|
|
|
sessionStorage.setItem("from", window.location.pathname);
|
2020-10-20 22:37:38 +08:00
|
|
|
|
return <Redirect to='/login' />
|
|
|
|
|
} else if (this.state.account === undefined) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return component;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isStartPages() {
|
|
|
|
|
return window.location.pathname.startsWith('/login') ||
|
2021-04-27 22:47:44 +08:00
|
|
|
|
window.location.pathname.startsWith('/signup') ||
|
2020-10-20 22:37:38 +08:00
|
|
|
|
window.location.pathname === '/';
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 09:46:01 +08:00
|
|
|
|
renderRouter(){
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Switch>
|
|
|
|
|
<Route exact path="/result" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
|
|
|
|
<Route exact path="/result/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
|
|
|
|
<Route exact path="/" render={(props) => this.renderLoginIfNotLoggedIn(<HomePage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/organizations/:organizationName" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationEditPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/organizations/:organizationName/users" render={(props) => this.renderLoginIfNotLoggedIn(<UserListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/users" render={(props) => this.renderLoginIfNotLoggedIn(<UserListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/users/:organizationName/:userName" render={(props) => <UserEditPage account={this.state.account} {...props} />}/>
|
2022-01-01 15:11:16 +08:00
|
|
|
|
<Route exact path="/roles" render={(props) => this.renderLoginIfNotLoggedIn(<RoleListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/roles/:organizationName/:roleName" render={(props) => this.renderLoginIfNotLoggedIn(<RoleEditPage account={this.state.account} {...props} />)}/>
|
2022-01-01 16:28:06 +08:00
|
|
|
|
<Route exact path="/permissions" render={(props) => this.renderLoginIfNotLoggedIn(<PermissionListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/permissions/:organizationName/:permissionName" render={(props) => this.renderLoginIfNotLoggedIn(<PermissionEditPage account={this.state.account} {...props} />)}/>
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Route exact path="/providers" render={(props) => this.renderLoginIfNotLoggedIn(<ProviderListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/providers/:providerName" render={(props) => this.renderLoginIfNotLoggedIn(<ProviderEditPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/applications" render={(props) => this.renderLoginIfNotLoggedIn(<ApplicationListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/applications/:applicationName" render={(props) => this.renderLoginIfNotLoggedIn(<ApplicationEditPage account={this.state.account} {...props} />)}/>
|
2021-08-15 00:17:53 +08:00
|
|
|
|
<Route exact path="/resources" render={(props) => this.renderLoginIfNotLoggedIn(<ResourceListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
{/*<Route exact path="/resources/:resourceName" render={(props) => this.renderLoginIfNotLoggedIn(<ResourceEditPage account={this.state.account} {...props} />)}/>*/}
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Route exact path="/ldap/:ldapId" render={(props) => this.renderLoginIfNotLoggedIn(<LdapEditPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/ldap/sync/:ldapId" render={(props) => this.renderLoginIfNotLoggedIn(<LdapSyncPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/tokens" render={(props) => this.renderLoginIfNotLoggedIn(<TokenListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/tokens/:tokenName" render={(props) => this.renderLoginIfNotLoggedIn(<TokenEditPage account={this.state.account} {...props} />)}/>
|
2021-11-07 15:41:24 +08:00
|
|
|
|
<Route exact path="/webhooks" render={(props) => this.renderLoginIfNotLoggedIn(<WebhookListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/webhooks/:webhookName" render={(props) => this.renderLoginIfNotLoggedIn(<WebhookEditPage account={this.state.account} {...props} />)}/>
|
2021-12-17 16:32:53 +08:00
|
|
|
|
<Route exact path="/syncers" render={(props) => this.renderLoginIfNotLoggedIn(<SyncerListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/syncers/:syncerName" render={(props) => this.renderLoginIfNotLoggedIn(<SyncerEditPage account={this.state.account} {...props} />)}/>
|
2021-12-31 00:36:36 +08:00
|
|
|
|
<Route exact path="/certs" render={(props) => this.renderLoginIfNotLoggedIn(<CertListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/certs/:certName" render={(props) => this.renderLoginIfNotLoggedIn(<CertEditPage account={this.state.account} {...props} />)}/>
|
2022-02-27 18:20:58 +08:00
|
|
|
|
<Route exact path="/products" render={(props) => this.renderLoginIfNotLoggedIn(<ProductListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/products/:productName" render={(props) => this.renderLoginIfNotLoggedIn(<ProductEditPage account={this.state.account} {...props} />)}/>
|
2022-02-27 23:50:35 +08:00
|
|
|
|
<Route exact path="/products/:productName/buy" render={(props) => this.renderLoginIfNotLoggedIn(<ProductBuyPage account={this.state.account} {...props} />)}/>
|
2022-02-05 01:18:13 +08:00
|
|
|
|
<Route exact path="/payments" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentListPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/payments/:paymentName" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentEditPage account={this.state.account} {...props} />)}/>
|
2022-03-13 18:05:16 +08:00
|
|
|
|
<Route exact path="/payments/:paymentName/result" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentResultPage account={this.state.account} {...props} />)}/>
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Route exact path="/records" render={(props) => this.renderLoginIfNotLoggedIn(<RecordListPage account={this.state.account} {...props} />)}/>
|
2021-09-25 14:54:13 +08:00
|
|
|
|
<Route exact path="/.well-known/openid-configuration" render={(props) => <OdicDiscoveryPage />}/>
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Route path="" render={() => <Result status="404" title="404 NOT FOUND" subTitle={i18next.t("general:Sorry, the page you visited does not exist.")}
|
|
|
|
|
extra={<a href="/"><Button type="primary">{i18next.t("general:Back Home")}</Button></a>} />} />
|
|
|
|
|
</Switch>
|
2021-07-23 09:46:01 +08:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
renderContent() {
|
2021-07-23 09:46:01 +08:00
|
|
|
|
if (!Setting.isMobile()) {
|
2021-11-06 22:04:20 +08:00
|
|
|
|
return (
|
|
|
|
|
<div style={{display: 'flex', flex: 'auto',width:"100%",flexDirection: 'column'}}>
|
|
|
|
|
<Layout style={{display: 'flex', alignItems: 'stretch'}}>
|
|
|
|
|
<Header style={{ padding: '0', marginBottom: '3px'}}>
|
|
|
|
|
{
|
|
|
|
|
Setting.isMobile() ? null : (
|
|
|
|
|
<Link to={"/"}>
|
|
|
|
|
<div className="logo" />
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-03-15 21:02:54 +08:00
|
|
|
|
<div>
|
|
|
|
|
<Menu
|
|
|
|
|
// theme="dark"
|
|
|
|
|
mode={(Setting.isMobile() && this.isStartPages()) ? "inline" : "horizontal"}
|
|
|
|
|
selectedKeys={[`${this.state.selectedMenuKey}`]}
|
|
|
|
|
style={{lineHeight: '64px', width: '80%', position: 'absolute'}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
this.renderMenu()
|
|
|
|
|
}
|
|
|
|
|
</Menu>
|
2021-11-06 22:04:20 +08:00
|
|
|
|
{
|
2022-03-15 21:02:54 +08:00
|
|
|
|
this.renderAccount()
|
2021-11-06 22:04:20 +08:00
|
|
|
|
}
|
2022-03-15 21:02:54 +08:00
|
|
|
|
<SelectLanguageBox/>
|
|
|
|
|
</div>
|
2021-11-06 22:04:20 +08:00
|
|
|
|
</Header>
|
|
|
|
|
<Layout style={{backgroundColor: "#f5f5f5", alignItems: 'stretch'}}>
|
|
|
|
|
<Card className="content-warp-card">
|
|
|
|
|
{
|
|
|
|
|
this.renderRouter()
|
|
|
|
|
}
|
|
|
|
|
</Card>
|
|
|
|
|
</Layout>
|
|
|
|
|
</Layout>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
2020-10-20 22:37:38 +08:00
|
|
|
|
<Header style={{ padding: '0', marginBottom: '3px'}}>
|
|
|
|
|
{
|
2021-03-26 21:58:19 +08:00
|
|
|
|
Setting.isMobile() ? null : (
|
|
|
|
|
<Link to={"/"}>
|
|
|
|
|
<div className="logo" />
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
2020-10-20 22:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
<Menu
|
|
|
|
|
// theme="dark"
|
|
|
|
|
mode={(Setting.isMobile() && this.isStartPages()) ? "inline" : "horizontal"}
|
2021-03-26 21:57:41 +08:00
|
|
|
|
selectedKeys={[`${this.state.selectedMenuKey}`]}
|
2021-11-06 22:04:20 +08:00
|
|
|
|
style={{ lineHeight: '64px' }}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
this.renderMenu()
|
|
|
|
|
}
|
2021-11-06 22:04:20 +08:00
|
|
|
|
<div style = {{float: 'right'}}>
|
2021-07-23 09:46:01 +08:00
|
|
|
|
{
|
2021-11-06 22:04:20 +08:00
|
|
|
|
this.renderAccount()
|
2021-07-23 09:46:01 +08:00
|
|
|
|
}
|
2021-11-06 22:04:20 +08:00
|
|
|
|
<SelectLanguageBox/>
|
|
|
|
|
</div>
|
|
|
|
|
</Menu>
|
|
|
|
|
</Header>
|
2021-07-23 09:46:01 +08:00
|
|
|
|
{
|
2021-11-06 22:04:20 +08:00
|
|
|
|
this.renderRouter()
|
2021-07-23 09:46:01 +08:00
|
|
|
|
}
|
2021-11-06 22:04:20 +08:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2020-10-20 22:37:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderFooter() {
|
|
|
|
|
// How to keep your footer where it belongs ?
|
|
|
|
|
// https://www.freecodecamp.org/neyarnws/how-to-keep-your-footer-where-it-belongs-59c6aa05c59c/
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Footer id="footer" style={
|
|
|
|
|
{
|
|
|
|
|
borderTop: '1px solid #e8e8e8',
|
|
|
|
|
backgroundColor: 'white',
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
}
|
|
|
|
|
}>
|
2021-07-18 17:50:50 +08:00
|
|
|
|
Made with <span style={{color: 'rgb(255, 255, 255)'}}>❤️</span> by <a style={{fontWeight: "bold", color: "black"}} target="_blank" href="https://casdoor.org" rel="noreferrer">Casdoor</a>
|
2020-10-20 22:37:38 +08:00
|
|
|
|
</Footer>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 16:43:30 +08:00
|
|
|
|
isDoorPages() {
|
2021-06-09 20:38:46 +08:00
|
|
|
|
return window.location.pathname.startsWith("/signup") ||
|
|
|
|
|
window.location.pathname.startsWith("/login") ||
|
|
|
|
|
window.location.pathname.startsWith("/callback") ||
|
2021-06-18 02:05:19 +08:00
|
|
|
|
window.location.pathname.startsWith("/prompt") ||
|
2022-04-04 00:09:04 +08:00
|
|
|
|
window.location.pathname.startsWith("/forget") ||
|
|
|
|
|
window.location.pathname.startsWith("/cas");
|
2021-02-11 16:43:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 19:51:03 +08:00
|
|
|
|
renderPage() {
|
2021-02-11 16:43:30 +08:00
|
|
|
|
if (this.isDoorPages()) {
|
|
|
|
|
return (
|
|
|
|
|
<Switch>
|
2021-10-09 21:15:57 +08:00
|
|
|
|
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account)}} />)}/>
|
|
|
|
|
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage account={this.state.account} {...props} />)}/>
|
|
|
|
|
<Route exact path="/signup/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signup"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account)}} />}/>
|
|
|
|
|
<Route exact path="/login/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signin"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account)}} />}/>
|
2022-04-08 23:06:48 +08:00
|
|
|
|
<Route exact path="/login/saml/authorize/:owner/:applicationName" render={(props) => <LoginPage account={this.state.account} type={"saml"} mode={"signin"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account)}} />}/>
|
2022-04-04 00:09:04 +08:00
|
|
|
|
<Route exact path="/cas/:owner/:casApplicationName/logout" render={(props) => this.renderHomeIfLoggedIn(<CasLogout clearAccount={() => this.setState({account: null})} {...props} />)} />
|
|
|
|
|
<Route exact path="/cas/:owner/:casApplicationName/login" render={(props) => {return (<LoginPage type={"cas"} mode={"signup"} account={this.state.account} {...props} />)}} />
|
2021-06-09 20:38:46 +08:00
|
|
|
|
<Route exact path="/callback" component={AuthCallback}/>
|
2021-12-06 21:46:50 +08:00
|
|
|
|
<Route exact path="/callback/saml" component={SamlCallback}/>
|
2021-06-09 20:38:46 +08:00
|
|
|
|
<Route exact path="/forget" render={(props) => this.renderHomeIfLoggedIn(<SelfForgetPage {...props} />)}/>
|
|
|
|
|
<Route exact path="/forget/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<ForgetPage {...props} />)}/>
|
2021-06-18 02:05:19 +08:00
|
|
|
|
<Route exact path="/prompt" render={(props) => this.renderLoginIfNotLoggedIn(<PromptPage account={this.state.account} {...props} />)}/>
|
2021-06-20 13:27:26 +08:00
|
|
|
|
<Route exact path="/prompt/:applicationName" render={(props) => this.renderLoginIfNotLoggedIn(<PromptPage account={this.state.account} onUpdateAccount={(account) => {this.onUpdateAccount(account)}} {...props} />)}/>
|
2021-08-06 18:03:05 +08:00
|
|
|
|
<Route path="" render={() => <Result status="404" title="404 NOT FOUND" subTitle={i18next.t("general:Sorry, the page you visited does not exist.")}
|
|
|
|
|
extra={<a href="/"><Button type="primary">{i18next.t("general:Back Home")}</Button></a>}/>} />
|
2021-02-11 16:43:30 +08:00
|
|
|
|
</Switch>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
return (
|
|
|
|
|
<div id="parent-area">
|
|
|
|
|
<BackTop />
|
2021-08-07 19:52:01 +08:00
|
|
|
|
<CustomGithubCorner />
|
2021-07-23 09:46:01 +08:00
|
|
|
|
<div id="content-wrap" style={{flexDirection: "column"}}>
|
2020-10-20 22:37:38 +08:00
|
|
|
|
{
|
|
|
|
|
this.renderContent()
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
{
|
|
|
|
|
this.renderFooter()
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-04-29 19:51:03 +08:00
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
if (this.state.account === undefined || this.state.account === null) {
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Helmet>
|
2022-02-13 23:34:29 +08:00
|
|
|
|
<link rel="icon" href={"https://cdn.casdoor.com/static/favicon.png"} />
|
2021-04-29 19:51:03 +08:00
|
|
|
|
</Helmet>
|
|
|
|
|
{
|
|
|
|
|
this.renderPage()
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const organization = this.state.account.organization;
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Helmet>
|
|
|
|
|
<title>{organization.displayName}</title>
|
2021-04-29 20:27:07 +08:00
|
|
|
|
<link rel="icon" href={organization.favicon} />
|
2021-04-29 19:51:03 +08:00
|
|
|
|
</Helmet>
|
|
|
|
|
{
|
|
|
|
|
this.renderPage()
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
2020-10-20 21:46:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 22:37:38 +08:00
|
|
|
|
export default withRouter(App);
|