diff --git a/adapter/src/components/LoginModal.js b/adapter/src/components/LoginModal.js index a67668f7..a91460be 100644 --- a/adapter/src/components/LoginModal.js +++ b/adapter/src/components/LoginModal.js @@ -17,13 +17,14 @@ import { styles } from './styles/LoginModal.style.js' // Check if base URL is set statically as an env var (typical in production) const staticUrl = process.env.REACT_APP_DHIS2_BASE_URL -const getUseNewLoginAPI = async (server) => { +const getIsNewLoginAPIAvailable = async (server) => { try { // if loginConfig is available, the instance can use new endpoints await get(`${server}/api/loginConfig`) return true } catch (e) { // if loginConfig is not available, the instance must use old endpoints + console.error(e) return false } } @@ -99,9 +100,11 @@ export const LoginModal = ({ appName, baseUrl, loginApp = false }) => { } } - const useNewLoginAPI = await getUseNewLoginAPI(server) + const isNewLoginAPIAvailable = await getIsNewLoginAPIAvailable( + server + ) - if (useNewLoginAPI) { + if (isNewLoginAPIAvailable) { loginWithNewEndpoints({ server, username, @@ -129,7 +132,7 @@ export const LoginModal = ({ appName, baseUrl, loginApp = false }) => { {error && (
- {error?.message || error?.details?.message} + {error?.message}
)} diff --git a/adapter/src/components/ServerVersionProvider.js b/adapter/src/components/ServerVersionProvider.js index 1e9c72e5..4429f4c5 100644 --- a/adapter/src/components/ServerVersionProvider.js +++ b/adapter/src/components/ServerVersionProvider.js @@ -194,7 +194,6 @@ export const ServerVersionProvider = ({ plugin={plugin} parentAlertsAdd={parentAlertsAdd} showAlertsInPlugin={showAlertsInPlugin} - skipApiVersion={loginApp ? true : false} > {children} diff --git a/adapter/src/index.js b/adapter/src/index.js index ed9113a8..1b80cf2d 100644 --- a/adapter/src/index.js +++ b/adapter/src/index.js @@ -65,7 +65,6 @@ const AppAdapter = ({ plugin={plugin} parentAlertsAdd={parentAlertsAdd} showAlertsInPlugin={showAlertsInPlugin} - setLoginBaseUrl={() => {}} > { }) .then((response) => { if (response.status !== 200) { - reject('Request failed ' + response.statusText) + response + .json() + .then((json) => { + reject(json) + }) + .catch(() => { + reject('Request failed ' + response.statusText) + }) return } try {