Adding all the code i changed. It now supports mfa, passkeys and passwords

This commit is contained in:
Janis Steiner
2024-12-25 23:56:19 +01:00
parent ea743d19e9
commit e8cba3edf6
49 changed files with 7730 additions and 24 deletions

View File

@@ -20,11 +20,16 @@
<div class="card shadow">
<div class="card-body">
<h4 class="card-title text-center mb-4">Jakach Login</h4>
<?php
if(isset($_GET["user_not_found"])){
echo("<div class='alert alert-danger'>Account not found!</div>");
}
?>
<!-- Form -->
<form id="usernameForm">
<!-- Username Input -->
<div class="mb-3">
<input type="text" id="username" name="username" class="form-control" placeholder="Benutzername" required>
<input type="text" autofocus id="username" name="username" class="form-control" placeholder="Benutzername" required>
</div>
<!-- Submit Button -->
<div class="d-grid gap-2">
@@ -40,6 +45,23 @@
</div>
</div>
<div class="modal fade" id="errorModal" tabindex="-1" aria-labelledby="errorModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="errorModalLabel">Error</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Account not found!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
// Select the form
const usernameForm = document.getElementById('usernameForm');
@@ -60,14 +82,15 @@
try {
// Send POST request to the API
const response = await fetch('/api/login/set_username.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username }), // Send username as JSON
});
const response = await fetch('/api/login/set_username.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded', // Form-like data
},
body: new URLSearchParams({
username: username, // Send username as form data
}),
});
// Check if the request was successful
if (response.ok) {
// Redirect to /login/ upon success
@@ -83,7 +106,19 @@
alert('An error occurred. Please try again later.');
}
});
</script>
</script>
<?php
// Check if the GET parameter "user_not_found" is set
if (isset($_GET["user_not_found"])) {
echo "
<script>
// Use JavaScript to trigger the modal to open
var errorModal = new bootstrap.Modal(document.getElementById('errorModal'));
errorModal.show();
</script>
";
}
?>
</body>
</html>