mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
Merge main into feature/marketplace
This commit is contained in:
122
public/example_login.html
Normal file
122
public/example_login.html
Normal file
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login & Register</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Login</h1>
|
||||
<form id="loginForm">
|
||||
<div>
|
||||
<label for="loginEmail">Email:</label>
|
||||
<input type="email" id="loginEmail" name="email" required>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="loginPassword">Password:</label>
|
||||
<input type="password" id="loginPassword" name="password" required>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<h1>Register</h1>
|
||||
<form id="registerForm">
|
||||
<div>
|
||||
<label for="regEmail">Email:</label>
|
||||
<input type="email" id="regEmail" name="email" required>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="regPassword">Password:</label>
|
||||
<input type="password" id="regPassword" name="password" required>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="regName">Name:</label>
|
||||
<input type="text" id="regName" name="name" required>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
|
||||
<h2>Response</h2>
|
||||
<pre id="response"></pre>
|
||||
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const email = document.getElementById('loginEmail').value;
|
||||
const password = document.getElementById('loginPassword').value;
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:8080/api/v1/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
document.getElementById('response').textContent = JSON.stringify(data, null, 2);
|
||||
|
||||
if (data.success && data.data.api_key) {
|
||||
localStorage.setItem('apiKey', data.data.api_key);
|
||||
alert('API Key saved to localStorage: ' + data.data.api_key);
|
||||
}
|
||||
} catch (error) {
|
||||
document.getElementById('response').textContent = 'Error: ' + error.message;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('registerForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const email = document.getElementById('regEmail').value;
|
||||
const password = document.getElementById('regPassword').value;
|
||||
const name = document.getElementById('regName').value;
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:8080/api/v1/auth/register', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password,
|
||||
name: name
|
||||
})
|
||||
});
|
||||
|
||||
const text = await response.text();
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch (e) {
|
||||
data = { error: 'Invalid JSON response', raw: text, status: response.status, statusText: response.statusText };
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
data = { ...data, httpError: `HTTP ${response.status}: ${response.statusText}` };
|
||||
}
|
||||
|
||||
document.getElementById('response').textContent = JSON.stringify(data, null, 2);
|
||||
|
||||
if (data.success && data.data.api_key) {
|
||||
localStorage.setItem('apiKey', data.data.api_key);
|
||||
alert('API Key saved to localStorage: ' + data.data.api_key);
|
||||
}
|
||||
} catch (error) {
|
||||
document.getElementById('response').textContent = 'Error: ' + error.message;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
38
public/themes/woiefhwoaeiglwejighfiwk-69eed7.css
Normal file
38
public/themes/woiefhwoaeiglwejighfiwk-69eed7.css
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user