diff --git a/public/app.js b/public/app.js index dfd3610..9cf6556 100644 --- a/public/app.js +++ b/public/app.js @@ -29,15 +29,27 @@ document.addEventListener('DOMContentLoaded', function() { const username = document.getElementById('username').value; const password = document.getElementById('password').value; - // Simple authentication check (replace with your own logic) - if (username === 'fredrik' && password === 'apa') { - sessionStorage.setItem('loggedIn', 'true'); - loginContainer.style.display = 'none'; - appContainer.style.display = 'block'; - loadTags(); - } else { - loginMessage.textContent = 'Invalid username or password'; - } + // Send credentials to the server for validation + fetch('/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Basic ' + btoa(username + ':' + password) + } + }) + .then(response => { + if (response.ok) { + sessionStorage.setItem('loggedIn', 'true'); + loginContainer.style.display = 'none'; + appContainer.style.display = 'block'; + loadTags(); + } else { + loginMessage.textContent = 'Invalid username or password'; + } + }) + .catch(error => { + loginMessage.textContent = 'Error logging in'; + }); }); document.getElementById('taskForm').addEventListener('submit', function(e) { diff --git a/public/index.html b/public/index.html index 87e067d..28e04fb 100644 --- a/public/index.html +++ b/public/index.html @@ -14,14 +14,14 @@