Init Discord OAuth2

This commit is contained in:
Arthur Puechberty
2026-01-14 23:58:42 +01:00
commit b18657e01c
7 changed files with 1288 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Connexion Discord</title>
</head>
<body>
<h1>Bienvenue !</h1>
<a href="/auth/discord">
<button>Se connecter avec Discord</button>
</a>
</body>
</html>
+23
View File
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Bienvenue</title>
</head>
<body>
<h1 id="greeting">Chargement...</h1>
<img id="avatar" src="" alt="Avatar">
<script>
// Récupérer l'objet user depuis le serveur
fetch("/api/user")
.then(res => res.json())
.then(user => {
document.getElementById("greeting").textContent = `Salut ${user.username}#${user.discriminator} !`;
document.getElementById("avatar").src = `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`;
})
.catch(() => {
document.getElementById("greeting").textContent = "Utilisateur non connecté.";
});
</script>
</body>
</html>