-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.html
More file actions
86 lines (73 loc) · 2.34 KB
/
Copy pathaccount.html
File metadata and controls
86 lines (73 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="module" src='/client_management.js'></script>
<title>Write Data Example</title>
</head>
<body>
<div>
<h1>sign in</h1>
<aside>please note: there is no account creation at the moment, as vulbyte is currently making sure the connection
is secure before allowing the site to be public :3</aside>
</div>
<div>
<div><label for="username">username</label><input id="username" type="text"></div>
<div><label for="password">password</label><input id="password" type="password"></div>
<div><button id="submit">submit</button></div>
<script type='module'>
// ====================== client_management.js ======================
import Networking from "/lib/networking.mjs"; // adjust path if needed
function LSGI(id) {
try {
return localStorage.getItem(id)
}
catch (err) {
throw new Error(err);
}
}
// helper shortcuts
function GEBI(id) {
return document.getElementById(id);
}
// create an instance (stateless until you call methods)
const net = new Networking();
window.addEventListener("DOMContentLoaded", () => {
const usernameInput = GEBI("username");
const passwordInput = GEBI("password");
const submitInput = GEBI("submit");
// optionally add a submit button dynamically or handle Enter key
passwordInput.addEventListener("keydown", async (e) => {
if (e.key === "Enter") {
await attemptSignIn();
}
});
submitInput.addEventListener("click", async (e) => {
await attemptSignIn();
});
async function attemptSignIn() {
const username = usernameInput.value.trim();
const password = passwordInput.value.trim();
if (!username || !password) {
alert("Please fill in both username and password");
return;
}
try {
console.log("Attempting to sign in...");
const result = await net.SignIn(username, password);
console.log("Server response:", result);
if (result?.jwt || result?.serverJWT) {
alert("Signed in successfully!");
} else {
alert("Sign-in failed or requires 2FA.");
}
} catch (err) {
console.error("Sign-in error:", err);
alert("Error signing in: " + err.message);
}
}
});
</script>
</div>
</body>
</html>