Implement server-side authentication and update login UI texts
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user