diff --git a/src/App.jsx b/src/App.jsx index 1eff2a7..e79ee89 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -24,6 +24,8 @@ import frenchMessages from "./i18n/fr"; import chineseMessages from "./i18n/zh"; 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? const messages = { de: germanMessages, @@ -42,7 +44,7 @@ const App = () => ( disableTelemetry requireAuth loginPage={LoginPage} - authProvider={authProvider} + authProvider={authProvider(fixed_base_url)} dataProvider={dataProvider} i18nProvider={i18nProvider} > diff --git a/src/components/LoginPage.jsx b/src/components/LoginPage.jsx index b81109e..3209003 100644 --- a/src/components/LoginPage.jsx +++ b/src/components/LoginPage.jsx @@ -81,7 +81,7 @@ const FormBox = styled(Box)(({ theme }) => ({ }, })); -const LoginPage = () => { +const LoginPage = ({ cfg_base_url }) => { const login = useLogin(); const notify = useNotify(); const [loading, setLoading] = useState(false); @@ -89,7 +89,6 @@ const LoginPage = () => { const [locale, setLocale] = useLocaleState(); const translate = useTranslate(); const base_url = localStorage.getItem("base_url"); - const cfg_base_url = process.env.REACT_APP_SERVER; const [ssoBaseUrl, setSSOBaseUrl] = useState(""); const loginToken = /\?loginToken=([a-zA-Z0-9_-]+)/.exec(window.location.href); @@ -247,7 +246,7 @@ const LoginPage = () => { name="base_url" component={renderInput} label="synapseadmin.auth.base_url" - disabled={cfg_base_url || loading} + disabled={cfg_base_url != null || loading} resettable fullWidth className="input" diff --git a/src/synapse/authProvider.js b/src/synapse/authProvider.js index 723f155..38e5071 100644 --- a/src/synapse/authProvider.js +++ b/src/synapse/authProvider.js @@ -1,10 +1,10 @@ import { fetchUtils } from "react-admin"; -const authProvider = { +const authProvider = fixed_base_url => ({ // called when the user attempts to log in login: ({ base_url, username, password, loginToken }) => { // 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 "); const options = { @@ -86,6 +86,6 @@ const authProvider = { }, // called when the user navigates to a new location, to check for permissions / roles getPermissions: () => Promise.resolve(), -}; +}); export default authProvider;