Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: login fallback error #19410

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@
}

@media (max-width: 600px) {
.nav-right img{
.nav-right img {
max-height: 34px;
width: 50px;
}
.right-content{
.right-content {
display: none;
}
.logo{
.logo {
max-height: 30px;
width: 60px;
}
Expand Down Expand Up @@ -284,11 +284,7 @@ <h1>Log in</h1>
</div>

<div id="twoFAContainer" style="display: none">
<input
type="text"
id="twoFA"
placeholder="TFA code"
/>
<input type="text" id="twoFA" placeholder="TFA code" />
</div>

<input type="submit" value="Log in" />
Expand All @@ -299,10 +295,18 @@ <h1>Log in</h1>
</div>

<!-- Notification -->
<div
class="notification-container"
>
<svg height="24" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="m12 2c5.5228475 0 10 4.4771525 10 10s-4.4771525 10-10 10-10-4.4771525-10-10 4.4771525-10 10-10zm1 9h-2v6h2zm-1-4c-.5522847 0-1 .44771525-1 1s.4477153 1 1 1 1-.44771525 1-1-.4477153-1-1-1z" fill="#093371"/></svg>
<div class="notification-container">
<svg
height="24"
viewBox="0 0 24 24"
width="20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="m12 2c5.5228475 0 10 4.4771525 10 10s-4.4771525 10-10 10-10-4.4771525-10-10 4.4771525-10 10-10zm1 9h-2v6h2zm-1-4c-.5522847 0-1 .44771525-1 1s.4477153 1 1 1 1-.44771525 1-1-.4477153-1-1-1z"
fill="#093371"
/>
</svg>
<div class="notification-content">
You are logging in using the fallback login page.
</div>
Expand All @@ -321,9 +325,10 @@ <h1>Log in</h1>
</div>

<script>
// 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 @@ -344,13 +349,11 @@ <h1>Log in</h1>
config.applicationTitle || "DHIS2 Login";
document.getElementById("appWelcomeMessage").innerText =
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.style.display = "block";
}

} catch (error) {
console.error("Error:", error);
}
Expand All @@ -360,7 +363,6 @@ <h1>Log in</h1>
const twoFAToggle = document.getElementById("twoFAToggle");
const twoFAContainer = document.getElementById("twoFAContainer");

// Function to toggle visibility based on checkbox state
const toggleTwoFAInput = () => {
if (twoFAToggle.checked) {
twoFAContainer.style.display = "block";
Expand All @@ -384,7 +386,7 @@ <h1>Log in</h1>
const submitButton = document.querySelector('input[type="submit"]');
const spinner = document.getElementById("spinner");
const errorMessage = document.getElementById("errorMessage");
const twoFA = document.getElementById("twoFA").value.trim(); // Trim whitespace
const twoFA = document.getElementById("twoFA").value.trim();

spinner.style.display = "block";
errorMessage.innerText = "";
Expand All @@ -398,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 Down
Loading