Skip to content

Commit

Permalink
feat: login fallback error (#19537)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Chisomchima authored Dec 23, 2024
1 parent 08018e1 commit 59dd5fd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
</div>
<img
class="logo"
src="/dhis-web-commons/security/logo_front.png"
src="./dhis-web-commons/security/logo_front.png"
alt="DHIS2 Logo"
/>
</div>
Expand Down Expand Up @@ -328,7 +328,7 @@ <h1>Log in</h1>
// 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;
Expand All @@ -351,7 +351,7 @@ <h1>Log in</h1>
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) {
Expand Down Expand Up @@ -400,7 +400,7 @@ <h1>Log in</h1>
}

try {
const response = await fetch("../api/auth/login", {
const response = await fetch("./api/auth/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -425,7 +425,7 @@ <h1>Log in</h1>
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);
Expand Down

0 comments on commit 59dd5fd

Please sign in to comment.