Repository navigation
Expand file tree
/
Copy pathauth.html
More file actions
94 lines (89 loc) · 2.41 KB
/
Copy pathauth.html
File metadata and controls
94 lines (89 loc) · 2.41 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
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Authenticating...</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #1e1e1e 0%, #2a2a2a 100%);
color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
margin: 0;
}
.auth-container {
background: rgba(42, 42, 42, 0.9);
padding: 2rem;
border-radius: 16px;
border: 2px solid #555;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
}
h1 {
color: #BB86FC;
margin-bottom: 1rem;
font-size: 1.8rem;
}
p {
color: #e0e0e0;
font-size: 1.1rem;
}
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid #555;
border-radius: 50%;
border-top-color: #BB86FC;
animation: spin 1s ease-in-out infinite;
margin-left: 0.5rem;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="auth-container">
<h1>Linking your Discord...</h1>
<p>Please wait.<span class="loading"></span></p>
</div>
<script>
async function handleAuth() {
const hash = window.location.hash.substring(1);
const params = new URLSearchParams(hash);
const token = params.get("access_token");
if (!token) {
document.querySelector('.auth-container').innerHTML = "<h1>Missing token.</h1>";
return;
}
try {
const res = await fetch("https://discord.com/api/users/@me", {
headers: { Authorization: `Bearer ${token}` }
});
const user = await res.json();
if (user && user.id) {
localStorage.setItem("discordUser", JSON.stringify({
id: user.id,
username: user.username,
discriminator: user.discriminator,
avatar: user.avatar,
token
}));
// Optional: show avatar on dashboard using user.avatar
}
// Redirect back to the dashboard
window.location.href = "index.html";
} catch (err) {
console.error("Auth failed", err);
document.querySelector('.auth-container').innerHTML = "<h1>Authentication failed.</h1>";
}
}
handleAuth();
</script>
</body>
</html>