From 59dd5fd9292058011197bb64bb269dc91c5bfb0d Mon Sep 17 00:00:00 2001 From: Chisom Chima <87203527+Chisomchima@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:51:48 +0100 Subject: [PATCH] feat: login fallback error (#19537) * feat: dynamically get url to make api calls * feat: dynamically get url to make api calls * fix: use relative path instead of dynamic url * feat: update relative path * chore: add relative paths for images --- .../resources/org/hisp/dhis/webapi/servlet/login.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dhis-2/dhis-web-api/src/main/resources/org/hisp/dhis/webapi/servlet/login.html b/dhis-2/dhis-web-api/src/main/resources/org/hisp/dhis/webapi/servlet/login.html index eb6c3f156269..a9775e915edd 100644 --- a/dhis-2/dhis-web-api/src/main/resources/org/hisp/dhis/webapi/servlet/login.html +++ b/dhis-2/dhis-web-api/src/main/resources/org/hisp/dhis/webapi/servlet/login.html @@ -250,7 +250,7 @@ @@ -328,7 +328,7 @@

Log in

// Fetch the login configuration dynamically async function fetchLoginConfig() { try { - const response = await fetch("../api/loginConfig"); + const response = await fetch("./api/loginConfig"); if (!response.ok) { let errorMessage = "Login failed: " + response.status; @@ -351,7 +351,7 @@

Log in

config.applicationDescription || "Welcome to the DHIS2 application"; if (config.countryFlag) { const flag = document.getElementById("flag"); - flag.src = `/dhis-web-commons/flags/${config.countryFlag}.png`; + flag.src = `./dhis-web-commons/flags/${config.countryFlag}.png`; flag.style.display = "block"; } } catch (error) { @@ -400,7 +400,7 @@

Log in

} try { - const response = await fetch("../api/auth/login", { + const response = await fetch("./api/auth/login", { method: "POST", headers: { "Content-Type": "application/json", @@ -425,7 +425,7 @@

Log in

const user = await response.json(); if (user.loginStatus === "SUCCESS") { - const redirectUrl = user.redirectUrl || "/"; + const redirectUrl = user.redirectUrl || "./"; window.location.href = redirectUrl; } else { throw new Error("Login failed. Status: " + user.loginStatus);