WIP: Extract process.env

Change-Id: I9efb1079c0c88e6e0272c5fda734a367aa8f84a3
This commit is contained in:
Manuel Stahl 2024-02-05 17:32:32 +01:00
parent 8688ab7d0e
commit 8c1546cd5a
3 changed files with 8 additions and 7 deletions

View File

@ -24,6 +24,8 @@ import frenchMessages from "./i18n/fr";
import chineseMessages from "./i18n/zh"; import chineseMessages from "./i18n/zh";
import italianMessages from "./i18n/it"; import italianMessages from "./i18n/it";
const fixed_base_url = undefined; // FIXME: process.env.REACT_APP_SERVER;
// TODO: Can we use lazy loading together with browser locale? // TODO: Can we use lazy loading together with browser locale?
const messages = { const messages = {
de: germanMessages, de: germanMessages,
@ -42,7 +44,7 @@ const App = () => (
disableTelemetry disableTelemetry
requireAuth requireAuth
loginPage={LoginPage} loginPage={LoginPage}
authProvider={authProvider} authProvider={authProvider(fixed_base_url)}
dataProvider={dataProvider} dataProvider={dataProvider}
i18nProvider={i18nProvider} i18nProvider={i18nProvider}
> >

View File

@ -81,7 +81,7 @@ const FormBox = styled(Box)(({ theme }) => ({
}, },
})); }));
const LoginPage = () => { const LoginPage = ({ cfg_base_url }) => {
const login = useLogin(); const login = useLogin();
const notify = useNotify(); const notify = useNotify();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@ -89,7 +89,6 @@ const LoginPage = () => {
const [locale, setLocale] = useLocaleState(); const [locale, setLocale] = useLocaleState();
const translate = useTranslate(); const translate = useTranslate();
const base_url = localStorage.getItem("base_url"); const base_url = localStorage.getItem("base_url");
const cfg_base_url = process.env.REACT_APP_SERVER;
const [ssoBaseUrl, setSSOBaseUrl] = useState(""); const [ssoBaseUrl, setSSOBaseUrl] = useState("");
const loginToken = /\?loginToken=([a-zA-Z0-9_-]+)/.exec(window.location.href); const loginToken = /\?loginToken=([a-zA-Z0-9_-]+)/.exec(window.location.href);
@ -247,7 +246,7 @@ const LoginPage = () => {
name="base_url" name="base_url"
component={renderInput} component={renderInput}
label="synapseadmin.auth.base_url" label="synapseadmin.auth.base_url"
disabled={cfg_base_url || loading} disabled={cfg_base_url != null || loading}
resettable resettable
fullWidth fullWidth
className="input" className="input"

View File

@ -1,10 +1,10 @@
import { fetchUtils } from "react-admin"; import { fetchUtils } from "react-admin";
const authProvider = { const authProvider = fixed_base_url => ({
// called when the user attempts to log in // called when the user attempts to log in
login: ({ base_url, username, password, loginToken }) => { login: ({ base_url, username, password, loginToken }) => {
// force homeserver for protection in case the form is manipulated // force homeserver for protection in case the form is manipulated
base_url = process.env.REACT_APP_SERVER || base_url; base_url = fixed_base_url || base_url;
console.log("login "); console.log("login ");
const options = { const options = {
@ -86,6 +86,6 @@ const authProvider = {
}, },
// called when the user navigates to a new location, to check for permissions / roles // called when the user navigates to a new location, to check for permissions / roles
getPermissions: () => Promise.resolve(), getPermissions: () => Promise.resolve(),
}; });
export default authProvider; export default authProvider;