diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/js/oidc/complete | |
add: graphs et rushs
Diffstat (limited to 'graphs/js/oidc/complete')
| -rw-r--r-- | graphs/js/oidc/complete/epita/index.html | 35 | ||||
| -rw-r--r-- | graphs/js/oidc/complete/epita/index.js | 40 |
2 files changed, 75 insertions, 0 deletions
diff --git a/graphs/js/oidc/complete/epita/index.html b/graphs/js/oidc/complete/epita/index.html new file mode 100644 index 0000000..2706a33 --- /dev/null +++ b/graphs/js/oidc/complete/epita/index.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <script defer src="./index.js" type="module"></script> + <link rel="stylesheet" href="../../style.css"> + </head> + <body> + <div class="card-container"> + <div class="img-container"> + <img class="round" id="image"src="https://cri.epita.fr/photos/square/puff" alt="user" width="225" height="225"/> + </div> + <h1 id="name">Puff Puff</h1> + <h3 id="campus">Marseille</h3> + <p id ="grad-year">2059</p> + + <div class="info-container"> + <div class="infos"> + <h3>infos</h3> + <ul id="list"> + </ul> + </div> + </div> + <div class="buttons"> + <button class="primary" id="RequestBtn"> + Request Infos + </button> + <button class="primary ghost" id="EndBtn"> + End Session + </button> + </div> + </div> + </body> +</html> diff --git a/graphs/js/oidc/complete/epita/index.js b/graphs/js/oidc/complete/epita/index.js new file mode 100644 index 0000000..513197c --- /dev/null +++ b/graphs/js/oidc/complete/epita/index.js @@ -0,0 +1,40 @@ +window.END_SESSION_URL = "https://cri.epita.fr/end-session"; +const reqInfosBtn = document.getElementById("RequestBtn"); +const params = new URLSearchParams(window.location.search); +const code = params.get("code"); + +let form = new FormData(); + +form.append("client_id", "assistants-atelier-js"); +form.append("redirect_uri", "http://localhost:8080/complete/epita/"); +form.append("grant_type", "authorization_code"); +form.append("code", code); +const tokenEndpoint = "http://localhost:8080/auth-api"; +reqInfosBtn.addEventListener("click", async () => { + let response = await fetch(tokenEndpoint, { + method: "POST", + body: form, + }); + const responsePretty = await response.json(); + const token = responsePretty.id_token; + const content = token.split(".")[1]; + const b64 = content.replace(/-/g, "+").replace(/_/g, "/"); + const payload = JSON.parse(window.atob(b64)); + + document.getElementById("name").innerHTML = payload.name; + document.getElementById("campus").innerHTML = payload.zoneinfo; + document.getElementById("grad-year").innerHTML = payload.graduation_years; + document + .getElementById("image") + .setAttribute("src", payload.picture_square); + const ul = document.getElementById("list"); + for (const group of payload.groups) { + const item = document.createElement("li"); + item.innerHTML = group.slug + " " + group.name; + ul.appendChild(item); + } +}); + +document + .getElementById("EndBtn") + .addEventListener("click", () => window.location.replace(END_SESSION_URL)); |
