-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (48 loc) · 1.67 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>
Scan the QR code below with Google Authenticator or any other compatible
app
</h1>
<img src="QR_CODE_DATA_URL" alt="Scan with Google Authenticator" />
<h2>Enter the code from the app</h2>
<input type="text" id="token" />
<button id="submit">Verify</button>
<p id="message"></p>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.7.7/axios.min.js"
integrity="sha512-DdX/YwF5e41Ok+AI81HI8f5/5UsoxCVT9GKYZRIzpLxb8Twz4ZwPPX+jQMwMhNQ9b5+zDEefc+dcvQoPWGNZ3g=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script>
const submit = document.getElementById("submit");
const token = document.getElementById("token");
const message = document.getElementById("message");
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
submit.addEventListener("click", async () => {
message.textContent = "";
await wait(250);
try {
const response = await axios.get(`/verify?token=${token.value}`);
const verified = response.data.verified;
if (verified) {
message.style.color = "green";
message.textContent = "Token is valid";
} else {
message.style.color = "red";
message.textContent = "Token is invalid";
}
} catch (error) {
message.textContent = error.response.data.message;
}
});
</script>
</body>
</html>