From 2fb3caf548e494baf0ce12ecfaa63ab2e8968a2a Mon Sep 17 00:00:00 2001 From: ami Date: Wed, 20 Nov 2024 18:59:58 -0500 Subject: [PATCH] Test username retrieve --- assets/js/get_username.js | 19 +++++++++++++++++++ index.html | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 assets/js/get_username.js diff --git a/assets/js/get_username.js b/assets/js/get_username.js new file mode 100644 index 0000000..0d77144 --- /dev/null +++ b/assets/js/get_username.js @@ -0,0 +1,19 @@ +async function getData() { + const url = "https://login.ami.sc/"; + try { + const response = await fetch(url); + + if (!response.ok) { + throw new Error(`Response status: ${response.status}`); + } + + const user_name = response.headers.get("X-Authentik-Name"); + console.log(user_name); + document.getElementById("username").innerHTML = user_name; + + } catch (error) { + console.error(error.message); + } +} + +getData(); diff --git a/index.html b/index.html index 4283bbb..942c16d 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,8 @@